Re: someVar to SOME_VAR
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Saturday, February 14, 2009, 5:09:34 PM, Alex7 wrote:
>
> Thanks,
>
> Actually looking to String built-ins I found regexp support :)
>
> The simplest way to do what I neede:
> ${data?replace('(\\p{Upper})', '_$1', 'r')?upper_case}
But if you use this at more than one place then, of course, wrap it
into a function:
<#function asConstName s>
<#return s?replace('(\\p{Upper})', '_$1', 'r')?upper_case>
</#function>
...
${asConstName(data)}
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H