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} <table> <tr><th>Product</th><th>Price</th><Quantity</th></tr> <tr> {foreach from=orders item=order} <tr> <td>{}</td> <td> {= order.price|currency} </td> <td>{order.qty}</td> </tr> {set total=order.price*order.qty+total} {/foreach} <p> Total price: {=total|currency} </p>

As described in LICENSE