JSPM

metalsmith-marko

0.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q24044F
  • License MIT

Metalsmith plugin to render files with Marko templates

Package Exports

  • metalsmith-marko

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (metalsmith-marko) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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