Computer Formatted Number Output in FreeMarker
Something any FreeMarker templater should know when creating links that contain numeric values:
From the FreeMarker reference:
Warning!
As you can see, interpolations print for human audience (by default at least), as opposed to “computer audience”. In some cases this is not good, like when you print a database record ID-s as the part of an URL or as an invisible field value in a HTML form, or when you print CSS/JavaScript numerical literals, because these printed values will be read by computer programs and not by humans. Most computer programs are very particular about the format of the numbers, and understand only a kind of simple US number formatting. For that, use the c (stands for “computer audience”) built-in, for example:
<a href=”/shop/productdetails?id=${product.id?c}”>Details…</a>
Enjoyed this post? Click to get future articles delivered by email or get the RSS feed.
