Can a freemarker interpolation contain an interpolation?

南楼画角 提交于 2020-01-04 01:36:15

问题


Let's say I have Freemarker variable A that contains the name of another variable on the hash tree, say. "B." I'd like to use a to read the value of B so, for example, if B contained "C" I could tell Freemarker to output C using A: ${${A}} should result in the output of "C". Naturally, this doesn't work in Freemarker, but is there a way to accomplish this?


回答1:


Use the .vars special variable, which is a hash (map) of the variables, and hence you can use the aHash[aKeyExpression] syntax:

${.vars[A]}

via Daniel Dekany, documentation author & maintainer



来源:https://stackoverflow.com/questions/2648933/can-a-freemarker-interpolation-contain-an-interpolation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!