I've got this code, which converts "dotted" string to camelCase in WebStorm File Template:
#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
For example it converts foo.bar.test
to FooBarTest
.
But what I need is to convert it from foo.bar.test
to fooBarTest
.
How can I do that?
The toLowerCase method converts a string to lowercase letters. The toLowerCase() method doesn't take in any parameters. Strings in JavaScript are immutable. The toLowerCase() method converts the string specified into a new one that consists of only lowercase letters and returns that value.
The Velocity Template Language (VTL) is meant to provide the easiest, simplest, and cleanest way to incorporate dynamic content in a web page. Even a web page developer with little or no programming experience should soon be capable of using VTL to incorporate dynamic content in a web site.
To declare a local variable inside a template, type: $ followed by a string beginning with a letter. A referenced Java object variable is provided by Report Wizard as shown in the following table (see the Linking Report Wizard template to MagicDraw section for a complete list of variables).
Approach 1: The obvious approach: Run and check. Run Velocity against the template to be checked. Look at the output and see if it is what you desired. This must be the most primitive testing approach, but most people nowadays are too lazy and want this done by the computer.
This is what finally worked for me:
#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
#set($first_letter = $Controller_name.substring(0,1).toLowerCase())
#set($the_rest = $Controller_name.substring(1))
#set($Controller_name = ${first_letter} + ${the_rest})
It could be shortened to:
#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
#set($Controller_name = $Controller_name.substring(0,1).toLowerCase() + $Controller_name.substring(1))
Thanks @LazyOne for pointing me in the right direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With