views:

58

answers:

1

Using freemarker, is there any way to reference a value indirectly along the lines of...

<#assign apple=fruit>
<#assign item=apple>
${${item}}

to produce the output 'fruit' without prior knowledge of what value item might contain?

+2  A: 

You can try using eval built-in:

${item?eval}

That would only work if item contains a valid expression, though. There's also an interpret built-in which treats your string as a full template, I haven't used it myself.

ChssPly76
That worked well, thanks.
Matt Sheppard