camelCase name in file template

Answered

Hi!

 

I want to create file name template. Here is 1 example: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206853275-File-templates-lower-upper-camel-case

#set( $NAME_CAMEL = ${StringUtils.removeAndHump( ${NAME} )} )

But it no longer works. It just leaves the case as it is. 

So I tried to use alternative way

${ Character.toLowerCase(${NAME}.charAt(0)) + ${NAME}.substring(1)} 

But Intellij says:

Unable to parse template "VtjPersonHandler" Error message: org.apache.velocity.runtime.parser.TemplateParseException: Encountered " " at MyTemplate[line 1, column 23] Was expecting:

How do I fix that?

0
3 comments

So basically, you want to have a class named MyClass, and the file itself named myClass.java, correct?

0

Rain

Inside the template, you can use this code:

#set($FIELD_NAME = $NAME.substring(0,1).toLowerCase() + $NAME.substring(1))
1

Thanks, that helped.

0

Please sign in to leave a comment.