A metalsmith plugin for twig
JavaScript HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json
yarn.lock

README.md

metalsmith-twig Build Status

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

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.
  • cache: (default: true) boolean if templatefiles cached.
  • twig: (default: undefined) overwirte the twig object.
  • allowInlineIncludes: (default: false) boolean if allow inline includes.

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

The MIT License (MIT)