I have the following variables defined:
def VAL1 = 'foo'
def VAL2 = 'bar'
def s2 = 'hello ${VAL1}, please have a ${VAL2}'
What is the easiest way to make this substitution work?
How could I build a GString from s2 and have it evaluated?
(VALs and s2 are loaded from database, this snippet is only for demonstrating my problem.)
You can use the
SimpleTemplateEngineif you can get your variables into a Map?edit
You can use the binding instead of the map, so the following works in the groovyconsole: