Demo for JavaScript Templates.
Edit the
JavaScript Template
and the input data. Press the Process button to see JST in action.
Input JST Template:
Hello ${customer.first} ${customer.last}.
Your shopping cart has ${products.length} item(s):
Name
Description
Price
Quantity & Alert
{for p in products}
${p.name|capitalize}
${p.desc}
$${p.price}
${p.quantity} : ${p.alert|default:""|capitalize}
{forelse}
No products in your cart.
{/for}
{if customer.level == "gold"} We love you! Please check out our Gold Customer specials! {else} Become a Gold Customer by buying more stuff here. {/if}
Input Data:
var data = { products : [ { name: "mac", desc: "computer", price: 1000, quantity: 100, alert:null }, { name: "ipod", desc: "music player", price: 200, quantity: 200, alert:"on sale now!" }, { name: "cinema display", desc: "screen", price: 800, quantity: 300, alert:"best deal!" } ], customer : { first: "John", last: "Public", level: "gold" } };
Output: