Groovy: Variable Substitution in dynamic Strings

Viewed 36624

I'm currently facing a variable substitution related problem in groovy. While this is quite trivial:

Map map = [s1:"Hello", s2:"World"]
println "${map.s1} ${map.s2}!" // "Hello World!"

As this works, I'm pretty sure that something like this should work as well:

Map map = [s1:"Hello", s2:"World"]
def dynamic = loadStringFromFile();

println "${dynamic} ${dynamic.class}" // "${s1} ${s2}! (java.lang.String)"

// now the voodoo part
println applyVoodoo(dynamic, map) // "Hello World!"

Does anybody know how to get this working?

Cheers

4 Answers
Related