twigify
twigify
is a Browserify transform for creating modules of pre-compiled Twig.js templates.
Installation
With npm
as a local development dependency:
npm install --save-dev twigify
Usage
In templates/test.twig
:
<h1>{{ title }}</h1>
In test.js
:
var template = ;var body = template;;
Including sub templates:
In templates/main.twig
:
<h1>{{ title }}</h1>{% include 'body.twig' %}
In main.js
:
// need to require() this so that it is available for main.twigvar bodyTemplate = ;var mainTemplate = ; var page = mainTemplate;;
Transforming with the command-line
browserify test.js -t twigify > test-bundle.js