Demo for ZParse.
Edit the template and the input data. Press the Process button to see ZParse in action.
Input Template:
Hello ${customer.first} ${customer.last}.
Your shopping cart has ${products.length} item(s):
Name
Description
Price
Quantity & Alert
<:foreach p in products:>
${p.name.toUpperCase()}
${p.desc}
$${p.price}
${p.quantity} : ${(p.alert||'').toUpperCase()}
<:/foreach:> <:else:>
No products in your cart.
<:/else:>
<:if customer.level == "gold":> We love you! Please check out our Gold Customer specials! <:/if:> <:else:> Become a Gold Customer by buying more stuff here. <:/else:>
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: "Lennon", level: "gold" } };
Output: