How can I use math in PhpStorm's Live Template?
For example, I have $Image_width$
in my template and want to set height image something like this:
<img width="$Image_width$" height="($Image_width$ / 2)">
You can use groovyScript()
function to define custom expressions - see https://www.jetbrains.com/help/phpstorm/template-variables.html#predefined_functions.
For example, for template like:
<img width="$Image_width$" height="$Image_width_half$">
you can specify groovyScript("def res=_1 as Integer; return res /2 ", Image_width)
as expression for $Image_width_half$
variable:
_1
here is a reference to first variable passed as a parameter to groovyScript()
function