在 PhpStorm 的实时模板中使用数学 [英] Use math in PhpStorm's Live Template
问题描述
如何在 PhpStorm 的实时模板中使用数学?
例如,我的模板中有 $Image_width$
并且想要设置像这样的高度图像:
您可以使用 groovyScript()
函数来定义自定义表达式 - 请参阅
_1
这里是对作为参数传递给 groovyScript()
函数的第一个变量的引用
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
这篇关于在 PhpStorm 的实时模板中使用数学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!