node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


Transformer Templating System

Transformer Template System

var Transformer = require('transformer')
var transformer = new Transformer
var myvars = {var1 : "Value1", var2: {field1: "Value 2"}}
var code = transformer.compile(input_text)
var output_text = transformer.execute(code, myvars)

Samples are present in the file tests/tests.js which shows how to use various features of Transformer. You can run the samples either by:

node tests/tests.js OR
npm test transformer

Sample template

To give an idea of how the transformer template looks, I have included a small example:

<h2>Order List</h2>

{set total=0}
{foreach from=orders item=order}
<td>{}</td> <td> {= order.price|currency} </td> <td>{order.qty}</td>
{set total=`order.price*order.qty+total`}
Total price: {=total|currency}

As described in LICENSE