metalsmith-jstransformer-partials v2.0.0
Metalsmith JSTransformer Partials 
Metalsmith plugin to add partial support through any JSTransformer.
Installation
npm install --save metalsmith-jstransformer-partialsCLI
If you are using the command-line version of Metalsmith, you can install via npm, and then add the metalsmith-jstransformer-partials key above metalsmith-jstransformer in your metalsmith.json file:
{
"plugins": {
"metalsmith-jstransformer-partials": {},
"metalsmith-jstransformer": {}
}
}JavaScript API
If you are using the JavaScript API for Metalsmith, then you can require the module and add it to your .use() directives above metalsmith-jstransformer:
var partials = require('metalsmith-jstransformer-partials');
var jstransformer = require('metalsmith-jstraxnsformer');
metalsmith.use(partials());
metalsmith.use(jstransformer());Usage
Partials are automatically defined in the partials/ directory, but you are able to define them manually by adding partials: true to your file metadata. The following example using Swig, so ensure you also install jstransformer-swig. To call a partial, invoke partial(<partialname>, locals) or `partials:
src/partials/name.swig
---
partial: true
name: Default Name
---
<div class="name">
<h2>Name: {{ name }}</h2>
</div>src/index.html.swig
<div class="name-wrapper">
{{ partial('name', { name: 'TJ Holowaychuk' })|safe }}
</div>Result
<div class="name-wrapper">
<div class="name">
<h2>Name: TJ Holowaychuk</h2>
</div>
</div>Options
.pattern
The pattern in which to automatically detect partials, without having to set partial: true. Defaults to partials/**.
.partials
An array of already existing partials to add to the array.
License
MIT
