Item template: Use uppercase for name

Answered

Hi,

 

is it possible to use the upper case version of the specified name in item templates? Imagine I want to create a new file called "myClass.ts" and specify the name "myClass", but the class name inside "myClass.ts" should be "MyClass" like 

export default class MyClass { ... }

I am using the ${NAME} variable btw. I'd like to do something like $upperFirstLetter{NAME}

 

0
2 comments

File templates in IntelliJ platform works through Apache Velocity. You can try using the following template:

#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
#set($first_letter = $Controller_name.substring(0,1).toUpperCase())
#set($the_rest = $Controller_name.substring(1))
#set($Controller_name = ${first_letter} + ${the_rest})

export default class $Controller_name {

}
0

Thanks for that! 

I'm not familiar with Apache Velocity, so thanks for the example.

0

Please sign in to leave a comment.