This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: JST: JavaScript Templates
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
You gotta love adding to "JS?" acronyms. Now we have JavaScript Templates, which, as Aslak talks about, can work well in the new world of Ajax.
Heres a JST sample that shows off some features like expressions, for loops, forelse, and if syntax
Hello ${customer.firstName|default:"Mr."} ${customer.lastName}<br/>
Your recent orders are:
<ul>
{for order in customer.getRecentOrders()}
<li>${order.orderNum} - ${order.status|capitalize}: ${order.grandTotal}
{if order.requestedShipDate < new Date().getTime() && order.status != "shipped"}
Please contact customer service.
{/if}
</li>
{forelse}
<li>You have no orders yet. </li>
{/for}
</ul>
With Ajax, I think we may see a trend of moving more and more into the world of JavaScript. People who maybe left it for dead years back (when it really was poor), will now see a slightly more mature language.
Sure, it isn't perfect, but it is installed in every browser that is out there
And, you can even do some AOP, so it MUST be cool ;)