JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 324
  • Score
    100M100P100Q83070F

Transformer Templating System

Package Exports

  • transformer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (transformer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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