transformer

Transformer Templating System

npm install transformer
9 downloads in the last week
35 downloads in the last month

Transformer Template System

Usage:


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

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:


<h1>{=page.title}</h1>
<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>{=order.name}</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>

License

As described in LICENSE

npm loves you