metalsmith-twig-540

A metalsmith plugin for [twig.js](https://github.com/justjohn/twig.js).

Usage no npm install needed!

<script type="module">
  import metalsmithTwig540 from 'https://cdn.skypack.dev/metalsmith-twig-540';
</script>

README

metalsmith-twig Build Status

A metalsmith Plugin for Twig based on justjohn/twig.js.

Forked by 540 to use unmerged twig cache fix.

Install

  npm install metalsmith-twig

Configuration in metalsmith.json:

{
  "plugins": {
    "metalsmith-twig": {}
  }
}

Examples

Initialize (INIT):

var Metalsmith = require('metalsmith'),
    Twig = require('metalsmith-twig');

Metalsmith(__dirname)
    .use(twig())
    .build(function(err) {
        if (err) throw err;
    });

Options:

  • directory: (default: views) the directory for views.
  • global: (default: {}) global variables.

Files

Source file src/index.md:

---
view: layout.html
title: The title
---
The Content

View

View views/layout.html:

<!doctype html>
<html>
    <head>
        <title>{{title}}</title>
    </head>
    <body>
        {{contents}}

        {{relativePath}}css/style.css
    </body>
</html>

Docs

Contributors

Philipp
Joe Critchley

The MIT License (MIT)