You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by Graham Ashby <Gr...@ca.ibm.com> on 2016/09/28 13:53:31 UTC
Port formatting in template
I'm having trouble with including a port in a template.
If the template has:
<value>${attribute['http.port']}</value>
And http.port is, say 9305, then the substituted value is "9,305" and not
"9305" This causes errors.
<value>9,305</value>
I could create an enricher to format the value, but is there another way?
Is there a way to force the substitution into just the digits, for
instance?
Thanks
Graham Ashby
IBM Canada
Re: Port formatting in template
Posted by Alex Heneveld <al...@cloudsoftcorp.com>.
I had the same thought. It didn't. :(
--A
On 28/09/2016 16:40, Svetoslav Neykov wrote:
> Locale.ROOT might work - worth a try.
>
> Svet.
>
>
>
>> On 28.09.2016 \u0433., at 18:30, Alex Heneveld <al...@cloudsoftcorp.com> wrote:
>>
>>
>> Grrr... This is one of the most irritating things about FreeMarker. It's described here:
>>
>> http://freemarker.org/docs/ref_builtins_number.html#ref_builtin_c
>>
>> Probably `?c` should be a default in our case, but there doesn't seem to be a possibility for that. We could set a specific locale in TemplateProcessor.processTemplateContents quite easily -- but are there any built-in locales which don't have grouping separators? I didn't see any. And defining a new locale and a NumberFormatProvider instance seems like stuff we shouldn't be doing...
>>
>> Best
>> Alex
>>
>>
>> On 28/09/2016 15:25, Svetoslav Neykov wrote:
>>> Hi Graham,
>>>
>>> You can tell freemarker (the template engine used) not to format the number by appending "?c" to the expression.
>>> See [1] for an example.
>>>
>>> Best,
>>> Svet.
>>>
>>>
>>> [1] https://github.com/apache/brooklyn-library/blob/master/software/database/src/main/resources/org/apache/brooklyn/entity/database/mysql/mysql_master.conf#L2
>>>
>>>
>>>> On 28.09.2016 \u0433., at 16:53, Graham Ashby <Gr...@ca.ibm.com> wrote:
>>>>
>>>> I'm having trouble with including a port in a template.
>>>>
>>>> If the template has:
>>>> <value>${attribute['http.port']}</value>
>>>>
>>>> And http.port is, say 9305, then the substituted value is "9,305" and not
>>>> "9305" This causes errors.
>>>> <value>9,305</value>
>>>>
>>>> I could create an enricher to format the value, but is there another way?
>>>> Is there a way to force the substitution into just the digits, for
>>>> instance?
>>>>
>>>> Thanks
>>>> Graham Ashby
>>>> IBM Canada
>>>>
Re: Port formatting in template
Posted by Svetoslav Neykov <sv...@cloudsoftcorp.com>.
Locale.ROOT might work - worth a try.
Svet.
> On 28.09.2016 г., at 18:30, Alex Heneveld <al...@cloudsoftcorp.com> wrote:
>
>
> Grrr... This is one of the most irritating things about FreeMarker. It's described here:
>
> http://freemarker.org/docs/ref_builtins_number.html#ref_builtin_c
>
> Probably `?c` should be a default in our case, but there doesn't seem to be a possibility for that. We could set a specific locale in TemplateProcessor.processTemplateContents quite easily -- but are there any built-in locales which don't have grouping separators? I didn't see any. And defining a new locale and a NumberFormatProvider instance seems like stuff we shouldn't be doing...
>
> Best
> Alex
>
>
> On 28/09/2016 15:25, Svetoslav Neykov wrote:
>> Hi Graham,
>>
>> You can tell freemarker (the template engine used) not to format the number by appending "?c" to the expression.
>> See [1] for an example.
>>
>> Best,
>> Svet.
>>
>>
>> [1] https://github.com/apache/brooklyn-library/blob/master/software/database/src/main/resources/org/apache/brooklyn/entity/database/mysql/mysql_master.conf#L2
>>
>>
>>> On 28.09.2016 г., at 16:53, Graham Ashby <Gr...@ca.ibm.com> wrote:
>>>
>>> I'm having trouble with including a port in a template.
>>>
>>> If the template has:
>>> <value>${attribute['http.port']}</value>
>>>
>>> And http.port is, say 9305, then the substituted value is "9,305" and not
>>> "9305" This causes errors.
>>> <value>9,305</value>
>>>
>>> I could create an enricher to format the value, but is there another way?
>>> Is there a way to force the substitution into just the digits, for
>>> instance?
>>>
>>> Thanks
>>> Graham Ashby
>>> IBM Canada
>>>
>
Re: Port formatting in template
Posted by Alex Heneveld <al...@cloudsoftcorp.com>.
Grrr... This is one of the most irritating things about FreeMarker.
It's described here:
http://freemarker.org/docs/ref_builtins_number.html#ref_builtin_c
Probably `?c` should be a default in our case, but there doesn't seem to
be a possibility for that. We could set a specific locale in
TemplateProcessor.processTemplateContents quite easily -- but are there
any built-in locales which don't have grouping separators? I didn't see
any. And defining a new locale and a NumberFormatProvider instance
seems like stuff we shouldn't be doing...
Best
Alex
On 28/09/2016 15:25, Svetoslav Neykov wrote:
> Hi Graham,
>
> You can tell freemarker (the template engine used) not to format the number by appending "?c" to the expression.
> See [1] for an example.
>
> Best,
> Svet.
>
>
> [1] https://github.com/apache/brooklyn-library/blob/master/software/database/src/main/resources/org/apache/brooklyn/entity/database/mysql/mysql_master.conf#L2
>
>
>> On 28.09.2016 \u0433., at 16:53, Graham Ashby <Gr...@ca.ibm.com> wrote:
>>
>> I'm having trouble with including a port in a template.
>>
>> If the template has:
>> <value>${attribute['http.port']}</value>
>>
>> And http.port is, say 9305, then the substituted value is "9,305" and not
>> "9305" This causes errors.
>> <value>9,305</value>
>>
>> I could create an enricher to format the value, but is there another way?
>> Is there a way to force the substitution into just the digits, for
>> instance?
>>
>> Thanks
>> Graham Ashby
>> IBM Canada
>>
Re: Port formatting in template
Posted by Svetoslav Neykov <sv...@cloudsoftcorp.com>.
Hi Graham,
You can tell freemarker (the template engine used) not to format the number by appending "?c" to the expression.
See [1] for an example.
Best,
Svet.
[1] https://github.com/apache/brooklyn-library/blob/master/software/database/src/main/resources/org/apache/brooklyn/entity/database/mysql/mysql_master.conf#L2
> On 28.09.2016 г., at 16:53, Graham Ashby <Gr...@ca.ibm.com> wrote:
>
> I'm having trouble with including a port in a template.
>
> If the template has:
> <value>${attribute['http.port']}</value>
>
> And http.port is, say 9305, then the substituted value is "9,305" and not
> "9305" This causes errors.
> <value>9,305</value>
>
> I could create an enricher to format the value, but is there another way?
> Is there a way to force the substitution into just the digits, for
> instance?
>
> Thanks
> Graham Ashby
> IBM Canada
>