开发者

Indirect reference in Freemarker

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜