mirror of
https://github.com/vale981/metalsmith-layouts
synced 2025-03-05 17:41:39 -05:00
57 lines
No EOL
1.1 KiB
Markdown
57 lines
No EOL
1.1 KiB
Markdown
|
|
# metalsmith-templates
|
|
|
|
A metalsmith plugin to render files with templates.
|
|
|
|
You can use any templating engine supported by [consolidate.js](https://github.com/visionmedia/consolidate.js).
|
|
|
|
## Installation
|
|
|
|
$ npm install metalsmith-templates
|
|
|
|
## CLI Usage
|
|
|
|
Install the node modules and then add the `metalsmith-templates` key to your `metalsmith.json` plugins. The simplest use case just requires the template engine you want to use:
|
|
|
|
```js
|
|
{
|
|
"plugins": {
|
|
"metalsmith-templates": "handlebars"
|
|
}
|
|
}
|
|
|
|
If you want to specify additional options, pass an object:
|
|
|
|
```json
|
|
{
|
|
"plugins": {
|
|
"metalsmith-templates": {
|
|
"engine": "handlebars",
|
|
"directory": "templates"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Javascript Usage
|
|
|
|
For the simplest use case, just pass your templating engine:
|
|
|
|
```js
|
|
var templates = require('metalsmith-templates');
|
|
|
|
metalsmith.use(templates('swig'));
|
|
```
|
|
|
|
Pass `options` to the templates plugin and pass it to Metalsmith with the `use` method:
|
|
|
|
```js
|
|
metalsmith.use(templates({
|
|
engine: 'swig',
|
|
directory: 'templates'
|
|
}));
|
|
```
|
|
|
|
## License
|
|
|
|
MIT |