Response title
This is preview!
Correct - for plain incoming JSON you won't have that advantage - this will mostly be an advantage for when you have objects (possibly instantiated from some base "class"?) floating around that you want to mush into a template.In the example there, the function is part of the object passed in to the template processor. It seems like the most common scenario would be that the object is json that came in off an ajax request, but of course there's a different solution for that...
Intuitively I would expect an "if" to consider all falsy values to be false. Perhaps this should be named ifdef instead?
I've reduced the templating syntax to three basic components: variable substitution, looping, and conditional (if/else) statements.
With that said, I just wanted to let people know that the code will not run on Safari, because some of the tmplcmds are keywords in JavaScript and Safari doesn't like that. So, they need to be quoted.
PHPTAL is a PHP implementation of ZPT work. To be short, PHPTAL is a XML/XHTML template library for PHP.
While most web developpers continue to use ASP/JSP/PHP tags as the core language of their templates, the Zope community came with a refreshing idea named TAL. The idea was to move presentation actions insideXHTML attributes instead of using plain tags or elements
<div class="item" tal:repeat="item itemsArray">
<span tal:condition="item/hasDate" tal:replace="item/getDate"/>
<a href="${item/getUrl}" tal:content="item/getTitle"/>
<p tal:content="value/getContent"/>
</div>
http://phptal.org/
${expr}
${expr|modifier}
${expr|modifier1|modifier2|...|modifierN}
${expr|modifier1:argExpr1_1}
${expr|modifier1:argExpr1_1,argExpr1_2,...,argExpr1_N}
${expr|modifier1:argExpr1_1,argExpr1_2|...|modifierN:argExprN_1,argExprN_2,...,argExprN_M}
Examples:
${customer.firstName}
${customer.firstName|capitalize}
${customer.firstName|default:"no name"|capitalize}
${article.getCreationDate()|default:new Date()|toCalenderControl:"YYYY.MM.DD",true, "Creation Date"}
${(lastQuarter.calcRevenue() - fixedCosts) / 1000000}
© 2013 jQuery Foundation
Sponsored by and others.