How to change the string news_type into NewsType by freemarker

is there any function for freemarker to change the string news_type into NewsType

Apr.12,2022

you can refer to my previous answer to this question
https://codeshelper.com/q/10...

.

it's just that your needs are reversed. Please refer to @ CloudFlying in the following code

<-sharpfunction dashedToCamel(s)>
    <-sharpreturn s
    ?replace('(^_+)|(_+$)', '', 'r')
    ?replace('\\_+(\\w)?', ' $1', 'r')
    ?replace('([A-Z])', ' $1', 'r')
    ?capitalize
    ?replace(' ' , '')
    ?uncap_first
    >
</-sharpfunction>
${dashedToCamel("___caMel___to_under_scOre_teSt____")}

output: caMelToUnderScOreTeSt
if you want the first letter to be capitalized, remove the line ? uncap_first from function.

Menu