metalsmith-partial

A metalsmith plugin to provide a 'partial' helper.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
metalsmith-partial
810.1.09 years ago9 years agoMinified + gzip package size for metalsmith-partial in KB

Readme

metalsmith-partial
A metalsmith plugin for a partial

This plugin provide 'partial' helper to include other templates. You can use any templating engine supported by consolidate.js.

Installation

$ npm install metalsmith-partial

Example

Source file src/index.html:

```html

title: The title

The contents


{%- @partial('foobar.html') %}
Partial `partials/foobar.html`:

```html
<p>This is a partial.</p>

Build file build.js:
var metalsmith = require('metalsmith');
var partial = require('metalsmith-partial');
var templates = require('metalsmith-templates');

metalsmith(__dirname)
  .source('./src')
  .destination('./dest')
  .use(partial({
    directory: './partials', 
    engine: 'eco'
  }))
  .use(templates({
    engine: 'eco',
    inPlace: true
  }))
  .build();

Results in dist/index.html:
<p>The contents</p>

<p>This is a partial</p>

License

MIT