twigged

0.9.0 • Public • Published

Build Status

About

Twigged is a pure JavaScript implementation of the Twig PHP templating language

The goal is to provide a library that is compatible with both browsers and server side JavaScript environments such as node.js.

Twigged is currently a work in progress and supports a limited subset of the Twig templating language (with more coming).

Node Usage (npm)

Twigged can be installed with NPM

npm install twigged

You can use Twigged in your app with

var Twig = require('twigged'), // Twig module
    twig = Twig.twig;         // Compile function

Browser Usage

Include the twig.js file on your page. The Twig global variable is then exposed.

Locally declare the render function twig like this:

var Twig = window.Twig, // Twig module
    twig = Twig.twig;   // Compile function

and you can then follow the next example.

Example usage

var template = twig({
    data: 'The {{ baked_good }} is a lie.'
});

console.log(
    template.render({baked_good: 'cupcake'})
);
// outputs: "The cupcake is a lie."

Contributing

If you have a change you want to make to Twigged, feel free to fork this repository and submit a pull request on Github.

The source files are located in src/*.js.

Twigged is built by running webpack

Tests

The Twigged tests are written in Mocha and can be invoked with npm test.

License

Twigged is available under a BSD 2-Clause License, see the LICENSE file for more information.

Acknowledgments

Twigged is a fork of the twig.js project which became unmaintained.

Readme

Keywords

none

Package Sidebar

Install

npm i twigged

Weekly Downloads

0

Version

0.9.0

License

none

Last publish

Collaborators

  • dave-irvine