LiveTemplates en groovy problem


I'm playing around with LiveTemplates. This is my template:

<qwerty $DEFAULT_VALUE$ />


When the $DEFAULT_VALUE$ is being filled with "blabla" I want to see

<qwerty defaultValue="blabla" />

and when it is empty, just:

<qwerty />

Seems a easy job…

I set the groovyscript in the variable screen for DEFAULT_VALUE to:

groovyScript("def v = _1; return v ? 'testing=\"' + v + '\"' : ''", DEFAULT_VALUE)

That doesn't work. I think because it is its own variable. When I add an $TESTING$ to the template, and use that in the groovy, then it works fine (but I don't want the $TESTING$ in the template).

I even tried ChatGPT, but that will come up with non-working solutions.

Would be nice when we could use the #if #end construction like in the code templates.

Am I missing things?

With kind regards,




Please sign in to leave a comment.