Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a string to camel case in phpstorms (velocity based) file tempates?

What I've tried so far is:

## $NAME is something like 'my_controller_c'
#set($NAME = $NAME.removeAndHump($NAME))
#set($NAME = $NAME.underscoresToCamelCase(String)

But that does not work. The first one does nothing, the second one throws an java error.

I also tried using regular expressions and to loop through the string, but my java knowledge is very basic.

like image 297
hugo der hungrige Avatar asked Dec 02 '22 18:12

hugo der hungrige


1 Answers

The following works in PhpStorm 9 (and probably all of the other JetBrains IDEs, I would guess):

#set($new_name = ${StringUtils.removeAndHump(${NAME}, "-")})

class $new_name {
}
like image 64
Andre Belzile Avatar answered Dec 26 '22 09:12

Andre Belzile