First-class JavaScript Twig compiler
Twing needs at least node.js 16.0.0 to run.
The recommended way to install Twing is via npm:
npm install twing --save
See the Twing website for documentation.
import {createEnvironment, createArrayLoader} from "twing";
const loader = createArrayLoader({
'index.twig': 'Everybody loves {{ name }}!'
});
const environment = createEnvironment(loader);
environment.render('index.twig', {name: 'Twing'}).then((output) => {
// output contains "Everybody loves Twing!"
});
Use jsdelivr CDN to include Twing in your HTML document:
<script src="https://cdn.jsdelivr.net/npm/twing/dist/lib.min.js"></script>
Once loaded by the browser, Twing is available under the global Twing
variable.
- gulp-twing: Compile Twig templates with gulp. Build upon Twing.
- twing-loader: Webpack loader that compiles Twig templates using Twing.
Copyright © 2018 Eric MORAND. Released under the 2-Clause BSD License.