rollup-plugin-mustache

0.1.0 • Public • Published

rollup-plugin-mustache

npm Dependencies Build Status Coverage Status JavaScript Standard Style

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

Tim De Pauw

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i rollup-plugin-mustache

Weekly Downloads

894

Version

0.1.0

License

MIT

Last publish

Collaborators

  • timdp