https://github.com/simbo/pug-frontmatter-html-loader
Webpack loader for rendering pug to html with frontmatter support.
https://github.com/simbo/pug-frontmatter-html-loader
Last synced: 4 months ago
JSON representation
Webpack loader for rendering pug to html with frontmatter support.
- Host: GitHub
- URL: https://github.com/simbo/pug-frontmatter-html-loader
- Owner: simbo
- License: mit
- Created: 2018-06-15T21:02:21.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-16T20:12:09.000Z (about 8 years ago)
- Last Synced: 2025-10-23T17:31:47.935Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 153 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pug-frontmatter-html-loader
===========================
> Webpack loader for rendering pug to html with frontmatter support.
---
[](https://www.npmjs.com/package/pug-frontmatter-html-loader)
[](https://travis-ci.org/simbo/pug-frontmatter-html-loader/builds)
[](https://coveralls.io/github/simbo/pug-frontmatter-html-loader?branch=master)
About
-----
`pug-frontmatter-html-loader` is a [webpack](https://webpack.js.org/) loader.
It renders [pug](https://pugjs.org/) templates to HTML using template data from
optional yaml frontmatter parsed with
[gray-matter](https://github.com/jonschlinkert/gray-matter).
Simple example pug template with frontmatter:
``` pug
---
content: "Hello World"
---
p= content
```
This gives you a convenient way to define more complex template data directly in
your template file. As frontmatter usage is optional, this can also be used as a
plain *pug to html* loader.
Installation
------------
`pug-frontmatter-html-loader` is a public npm package. You can install it using
npm:
``` sh
npm i -D pug-frontmatter-html-loader
```
Usage
-----
Simply add it as a loader in your webpack config's module rules:
``` js
{
module: {
rules: [
{
test: /\.pug$/,
use: ['pug-frontmatter-html-loader']
}
]
}
}
```
This loader outputs strings. If you want to use them in javascript context,
prepend the [raw-loader](https://github.com/webpack-contrib/raw-loader) to your
loader chain.
Options
-------
See [pug compiler options](https://pugjs.org/api/reference.html#options).
License
-------
[MIT @ 2018 Simon Lepel](http://simbo.mit-license.org/)