About FreeMarker, is it possible to instruct it to treat all numbers as "computer" ones by default?
I tried to apply
cfg.setSetting(Configurable.NUMBER_FORMAT_KEY, "computer");
or
cfg.setNumberFormat("computer");
to configuration object, but the outcome is not the desired. Believing this is the documentation's way to do it, is there anything wrong?
c (when used with numerical value) This built-in converts a number to string for a "computer language" as opposed to for human audience. That is, it formats with the rules that programming languages used to use, which is independent of all the locale and number format settings of FreeMarker.
eval. This built-in evaluates a string as an FTL expression. For example "1+2"? eval returns the number 3. (To render a template that's stored in a string, use the interpret built-in instead.)
FreeMarker is a Java based template engine from the Apache Software Foundation. Like other template engines, FreeMarker is designed to support HTML web pages in applications following the MVC pattern.
The number format you specify must be something that java.text.DecimalFormat
supports. The closest thing you can do right now is switching the locale to en_US
(and better ensure that it doesn't use groping; see http://freemarker.org/docs/app_faq.html#faq_number_grouping). Or, of course, you can write ?c
-s all over, but I suppose that's what you wanted to avoid.
Try with:
cfg.setNumberFormat("#");
It worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With