freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G Kal (Jira)" <>
Subject [jira] [Commented] (FREEMARKER-157) Custom number formats
Date Mon, 14 Sep 2020 06:47:00 GMT


G Kal commented on FREEMARKER-157:

Hello [~ddekany], and thank you for your response. Indeed that was the problem. My understanding
was that the ?string.@base_8 will work with both strings and numbers. Since I cannot always
say if the value of that map would be number or string is there another way to call the formatter
explicitly in both situations ?

For now I used ${map.key?number?string.@base_8} to first transform my value into a number
and then into a string, but is there another way which is not so verbose ?

> Custom number formats
> ---------------------
>                 Key: FREEMARKER-157
>                 URL:
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: documentation
>    Affects Versions: 2.3.28, 2.3.29, 2.3.30
>            Reporter: G Kal
>            Priority: Major
>              Labels: customNumberFormats
> Followed the exact steps as described at the project's [documentation|]
but I cannot make my custom number formats to work.
> For example when I run the template bellow:
> {code:java}
> ${map.key?string.@base_8}
> {code}
>  I get this error:
> {code:java}
> For "." left-hand operand: Expected a hash, but this has evaluated to a string (wrapper:
> ==> map.key?string
> {code}
> I tried various combinations of . and @ operator, tried to wrap my map inside () but
nothing seems to work.
> Setting the number format globally (<#setting number_format="@base_8">) works,
but this is not an option for me, as well as the model - aware formats. Is this functionality
broken or removed, can I at least have a custom format function ? How can I achieve this?

This message was sent by Atlassian Jira

View raw message