No description
Find a file
2015-07-25 11:22:36 +02:00
lib Add dotfiles 2015-07-25 11:22:36 +02:00
test Add dotfiles 2015-07-25 11:22:36 +02:00
.editorconfig Add dotfiles 2015-07-25 11:22:36 +02:00
.eslintrc Add dotfiles 2015-07-25 11:22:36 +02:00
.gitattributes Add dotfiles 2015-07-25 11:22:36 +02:00
.gitignore first commit 2014-02-04 21:47:35 -08:00
.travis.yml Add travis 2015-07-16 21:05:15 +02:00
History.md 1.1.0 2015-07-19 22:07:58 +02:00
Makefile Add dotfiles 2015-07-25 11:22:36 +02:00
package.json Add dotfiles 2015-07-25 11:22:36 +02:00
Readme.md Add badges 2015-07-23 21:47:32 +02:00

metalsmith-layouts

npm Build Status Dependency Status devDependency Status npm

A metalsmith plugin for layouts

This plugin passes your source files to a template as contents and renders it with the templating engine of your choice. You can use any templating engine supported by consolidate.js. Pass options to it with the Javascript API or CLI. The options are:

  • engine: templating engine (required)
  • default: default template (optional)
  • directory: directory for the layouts, layouts by default (optional)
  • pattern: only files that match this pattern will be processed (optional)

Installation

$ npm install metalsmith-layouts

Example

Configuration in metalsmith.json:

{
  "plugins": {
    "metalsmith-layouts": {
      "engine": "handlebars"
    }
  }
}

Source file src/index.html:

---
layout: layout.html
title: The title
---
<p>The contents</p>

Layout layouts/layout.html:

<!doctype html>
<html>
<head>
  <title>{{title}}</title>
</head>
<body>
{{{contents}}}
</body>
</html>

Results in dist/index.html:

<!doctype html>
<html>
<head>
  <title>The title</title>
</head>
<body>
  <p>The contents</p>
</body>
</html>

Origins

This plugin originated in metalsmith-templates issue #35. Splitting up metalsmith-templates into two plugins was suggested by Ian Storm Taylor. The results are:

Both plugins have been optimised for each use case. For metalsmith-layouts the differences with metalsmith-templates are:

  • The inPlace option has been removed
  • Use layout instead of template in the front-matter to specify a layout
  • The default folder for layouts is layouts instead of templates

For further documentation see the original metalsmith-templates, but keep these differences in mind.

License

MIT