Merge pull request #10 from Rydez/master

Add documentation for using Pug
This commit is contained in:
Gianluca Guarini 2019-08-03 18:17:02 +02:00 committed by GitHub
commit 951bd76ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,7 +37,30 @@ module.exports = {
// add here all the other @riotjs/compiler options riot.js.org/compiler // add here all the other @riotjs/compiler options riot.js.org/compiler
// template: 'pug' for example // template: 'pug' for example
} }
```
If you want to use `pug` as your template engine, your `riot.config.js` might look like this
```js
const { registerPreprocessor } = require('@riotjs/compiler')
const { render } = require('pug')
// register the pug preprocessor
registerPreprocessor('template', 'pug', (code, options) => {
const { file } = options
return {
code: render(code, {
filename: file,
pretty: true,
doctype: 'html'
})
}
})
module.exports = {
template: 'pug'
}
``` ```
If you want to enable hmr via `hot` option you will need to install also [`@riotjs/hot-reload`](https://www.npmjs.com/package/@riotjs/hot-reload) If you want to enable hmr via `hot` option you will need to install also [`@riotjs/hot-reload`](https://www.npmjs.com/package/@riotjs/hot-reload)