front-matter-pug
v1.0.0
Published
Parse Front Matter from a Pug comment
Downloads
1,012
Maintainers
Readme
front-matter-pug
Parse Front Matter from a Pug comment
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