Search code examples
phpstormlive-templates

PhpStorm combine multiple Predefined Live Template functions


I have a project where my files are in "lisp-case" (hyphen delimited) and I would like to use the filename as a variable in a live template, but it must be converted to CamelCase first.

I found out that you can set the expression fileNameWithoutExtension() under "Edit Template Variables" and there is also a function called camelCase() which should be able to turn my filenames into CamelCase. But I cannot figure out how to combine those two. I tried doing camelCase(fileNameWithoutExtension()) but that does not work, unfortunately.

Is it possible to achieve this some other way?

enter image description here


Solution

  • camelCase(fileNameWithoutExtension())

    It's a correct syntax.

    Is it possible to achieve this some other way?

    Please ensure that Skip if defined checkbox is checked for this variable.

    enter image description here

    If I try to wrap fileNameWithoutExtension() inside camelCase() and press enter to save the entry the window is closed but the change is not saved

    It's an IDE bug (https://youtrack.jetbrains.com/issue/IDEA-132965 -- supposed to be fixed in current 2017.1.x version).

    In any case: either press Enter before leaving the field ... or click on OK button straight away (you may then reopen this window to do further changes).

    Also, when editing the field it's rendered like a select box which is kind of weird. Maybe it's a bug in this specific version. I'm on PhpStorm 10.0.4 for Mac.

    Not a Mac user here .. but it is an editable drop-down box indeed (it lists all possible functions).

    enter image description here