rollup-plugin-mustache
v0.1.0
Published
Precompiles Mustache templates using Hogan.js.
Downloads
4,208
Readme
rollup-plugin-mustache
Precompiles Mustache templates using Hogan.js.
Installation
npm install --save-dev rollup-plugin-mustache
Usage
First, configure Rollup:
import mustache from 'rollup-plugin-mustache'
import commonjs from 'rollup-plugin-commonjs'
export default {
entry: 'src/index.js',
dest: 'dist/my-lib.js',
plugins: [
// ... other plugins here ...
mustache({
include: '**/*.mustache'
}),
commonjs() // Needed to import Hogan.js
]
}
Then, import a template and render it:
import mainTemplate from './main.mustache'
const html = mainTemplate.render({
foo: 'bar',
baz: 'quux'
})
console.log(html)
Options
hoganKey
By default, this plugin will import Hogan.js into your build. If you already
have it imported some other way, you should most likely override the hoganKey
option with just 'hogan.js'
and let Rollup resolve it. Alternatively, you can
specify the full path to the main file.
include
and exclude
From rollup-pluginutils.
Author
License
MIT