Live Templates

Hi Everyone, I'm trying to create some live templates and file templates in Rider. How can I insert a variable that will convert the Controller name (MVC) to camel case. Example is if I am inserting a function in TestController, the output of the variable should only be "test".

Also, is there a macro that can be assigned to a variable to replace part of the class name to whatever string I want? E.g. if the $CLASS$ variable is equal to "TestClassVM", the output of the macro for the other variable should be "TestClassRH", replacing VM with RH?

Thank you in advance.

1 comment
Comment actions Permalink

Hey Edward Carandang

I'd suggest using camelCase(<String>) function of Live Templates feature. For example, camelCase("my-text-file")camelCase("my text file"), and camelCase("my_text_file") all return myTextFile. Please find more here:  https://www.jetbrains.com/help/rider/template_variables.html#predefined_functions

Turning "TestClassVM" to "TestClassRH" is not possible in Rider at the moment, I'm afraid. At least until the advanced naming rules are implemented, see https://youtrack.jetbrains.com/issue/RIDER-8339

Hope it helps!

0

Please sign in to leave a comment.