开发者

Indirect reference in Freemarker

开发者 https://www.devze.com 2022-12-10 16:06 出处:网络
Using freemarker, is there any way to reference a value indirectly along the lines of... <#assign apple=fruit>

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

精彩评论

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