Home

Awesome

rollup-plugin-twig

build status stability npm version js-standard-style semantic-release

Rollup plugin that imports pre-compiled Twig.js templates.

Installation

NPM

npm install rollup-plugin-twig --save-dev

Usage

Configure Rollup with rollup-plugin-twig :

import { rollup } from 'rollup'
import twig from 'rollup-plugin-twig'

rollup({
  entry: 'src/main.js',
  plugins: [
    twig()
  ]
}).then(...)

Create a template :

<div>{{ foo }}</div>

Import the template and render it with data (optional) :

import template from './template.twig'

const data = { foo: 'bar' }
console.log(template.render(data)) // <div>bar</div>

Options

Plugin options you can pass :

Build

To build the sources with rollup in ./lib directory :

npm run build

Testing

To run the tests, first clone the repository and install its dependencies :

git clone https://github.com/fm_ph/rollup-plugin-twig.git
cd rollup-plugin-twig
npm install

Then, run the tests :

npm test

To watch (test-driven development) :

npm run test:watch

For coverage :

npm run test:coverage

License

MIT License © Patrick Heng Fabien Motte