Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

metalsmith-marko

steverandy19MIT0.3.0

Metalsmith plugin to render files with Marko templates

metalsmith, plugin, template, marko

readme

metalsmith-marko

A Metalsmith plugin to render files with Marko templates.

It supports rendering source files with templates and layouts. By default it looks for layout files in layouts directory. You need to set the layout in source file frontmatter section in order to render it in a layout. Optionally, you can set defaultLayout in plugin options.

Installation

$ npm install metalsmith-marko

Usage

Without Options

let marko = require("metalsmith-marko")

metalsmith.use(marko())

With Options

let marko = require("metalsmith-marko")

metalsmith.use(marko({
  layoutsDirectory: "layouts",
  defaultLayout: "default.html",
  pattern: ["**/*.marko", "**/*.html"],
  compilerOptions: {
    writeToDisk: false,
    preserveWhitespace: true
  }
}))

Default Options

layoutsDirectory: "layouts",
pattern: ["**/*.marko"],
compilerOptions: {
  writeToDisk: false,
  preserveWhitespace: true
}

Templates

layouts/default.html.marko

<!DOCTYPE html>
<html>
<head>
  <title>${data.title}</title>
</head>
<body>
  $!{data.contents}
</body>
</html>

pages/index.html.marko

<article>
  <h1>Heading</h1>
  <div for(page in data.pages)>${page.title}</div>
</article>

License

MIT License