Indo direto pra categoria "pq diabos eu nao pensei nisso antes", JavaScript Templates:
http://trimpath.com/project/wiki/JavaScriptTemplates
JavaScript Templates let’s you do template-style programming (like PHP/ASP/JSP) completely in your web browser. It’s an open-source tool to help make writing new-fangled rich web applications easier, like OddPost/GMail/Bloglines.Here’s 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> The code within the ${…} and {for …} and {if …} markup is just standard JavaScript, so you’re not learning yet another new expression language.