Precompiles Mustache templates using Hogan.js.
npm install --save-dev rollup-plugin-mustache
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)
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.
From rollup-pluginutils.
MIT