camelCase name in file template

已回答

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?

评论操作 固定链接

Rain

Inside the template, you can use this code:

#set($FIELD_NAME = $NAME.substring(0,1).toLowerCase() + $NAME.substring(1))
1
评论操作 固定链接

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

0
评论操作 固定链接

Thanks, that helped.

0

请先登录再写评论。