Add lib-string.ftl for functions and macros for string manipulation. Add two methods, one for camelcasing and one for uncamelcasing.
This commit is contained in:
parent
bb7444cf4c
commit
bb984ccaea
3 changed files with 26 additions and 1 deletions
17
webapp/web/templates/freemarker/lib/lib-string.ftl
Normal file
17
webapp/web/templates/freemarker/lib/lib-string.ftl
Normal file
|
@ -0,0 +1,17 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Macros and functions for string manipulation -->
|
||||
|
||||
<#function camelCase str>
|
||||
<#return str?capitalize?replace(" ", "")?uncap_first>
|
||||
</#function>
|
||||
|
||||
<#function unCamelCase str>
|
||||
<#local str = str?replace("([a-z])([A-Z])", "$1 $2", "r")>
|
||||
<#local words = str?split(" ")>
|
||||
<#local out = "">
|
||||
<#list words as word>
|
||||
<#local out = out + " " + word?uncap_first>
|
||||
</#list>
|
||||
<#return out?trim>
|
||||
</#function>
|
Loading…
Add table
Add a link
Reference in a new issue