An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

pug-frontmatter-html-loader
===========================

> Webpack loader for rendering pug to html with frontmatter support.

---

[![npm package version](https://img.shields.io/npm/v/pug-frontmatter-html-loader.svg?style=flat-square)](https://www.npmjs.com/package/pug-frontmatter-html-loader)
[![Travis CI build status](https://travis-ci.org/simbo/pug-frontmatter-html-loader.svg?branch=master)](https://travis-ci.org/simbo/pug-frontmatter-html-loader/builds)
[![Coverage Status](https://coveralls.io/repos/github/simbo/pug-frontmatter-html-loader/badge.svg?branch=master)](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/)