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:
rjy7 2011-02-11 15:12:11 +00:00
parent bb7444cf4c
commit bb984ccaea
3 changed files with 26 additions and 1 deletions

View 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>