front-matter-pug

Parse Front Matter from a Pug comment

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
front-matter-pug
101.0.06 years ago6 years agoMinified + gzip package size for front-matter-pug in KB

Readme

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