1.0.0 • Published 7 years ago

front-matter-pug v1.0.0

Weekly downloads
1,101
License
MIT
Repository
github
Last release
7 years ago

front-matter-pug

Parse Front Matter from a Pug comment

Travis npm

Installation

npm install front-matter-pug

Usage

const fm = require('front-matter-pug');

const pug = `//-
  kittens: true
  puppies: true
  lizards: false
  ---

!doctype
html
  body
`;

const content = fm(pug);

API

fm(pug)

Parse YAML Front Matter from a comment at the top of a Pug/Jade document.

  • pug (String): input Pug code.

Returns an object with these properties:

  • attributes (Object): extracted YAML.
  • body (String): Pug code without Front Matter comment.
  • frontmatter (String): original YAML string.

fm.test(pug)

Test if a Pug/Jade document contains a Front Matter block within a block comment (//-).

Returns true or false.

Local Development

git clone https://github.com/gakimball/front-matter-pug
cd front-matter-pug
npm install
npm test

License

MIT © Geoff Kimball