Live templates - providing default values from the template text 关注
已回答
Hey,
I know I can set defaults values with the UI ("Edit Variables"), but any way to do that directly with the syntax in the snippet? For instance:
foo = $bar$ * 2
Let's say I want "bar" to be 42 by default.
请先登录再写评论。
You can use groovyScript to check the value of the variable passed to the template and set it to something different if not provided: https://stackoverflow.com/questions/35405836/how-to-pass-variable-to-groovy-code-in-intellij-idea-live-templates-groovy-scrip.