Spry update on the way

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> </code>

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”> </code>

This could really simplify complex display code. When will this be released? Soon…

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments