A little birdie just let me know that a very cool Spry update is on the way. It includes a feature I've been asking about for a while now - custom display functions. What do I mean? Consider the following example (thanks Donald Booth for the code):
<script type="text/javascript">
function FormattedPrice(region, lookupFunc)
{
return "$" + parseInt(lookupFunc("{dsProducts::price}")).toFixed(2);
}
</script>
...
<div spry:region="dsProducts">
<ul spry:repeatchildren="dsProducts">
<li>{name} - {function::FormattedPrice} </li>
</ul>
</div>
Spry will now recognize function:: as a custom JavaScript function. In this example, it formats a price to include a dollar sign and 2 decimal places.
You can even use functions in conditions. Consider:
<script>
function checkName(rgn, doIt)
{
return doIt('{name}') == 'Adobe Studio 8';
}
</script>
<div spry:if="function::checkName">
This could really simplify complex display code. When will this be released? Soon...