Skip to content

timdp/rollup-plugin-mustache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Precompiles Mustache templates using Hogan.js.

Resources

License

Stars

Watchers

Forks

Packages

No packages published