A metalsmith Plugin for Twig based on justjohn/twig.js.
npm install metalsmith-twigConfiguration in metalsmith.json:
{
"plugins": {
"metalsmith-twig": {}
}
}
var Metalsmith = require('metalsmith'),
Twig = require('metalsmith-twig');
Metalsmith(__dirname)
.use(twig())
.build(function(err) {
if (err) throw err;
});directory: (default: views) the directory for views.global: (default: {}) global variables.cache: (default: true) boolean if templatefiles cached.twig: (default: undefined) overwrite the twig object.allowInlineIncludes: (default: false) boolean if allow inline includes.namespaces: (default: false) object with namespaces key => value (see twig.js project for more details).
Source file src/index.md:
---
view: layout.html
title: The title
---
The ContentView views/layout.html:
<!doctype html>
<html>
<head>
<title>{{title}}</title>
</head>
<body>
{{contents}}
{{relativePath}}css/style.css
</body>
</html>- Twig.js github.com/justjohn/twig.js
- Twig twig.sensiolabs.org