Freemarker: Dynamic interpolation of sub variables

前端 未结 1 832
醉梦人生
醉梦人生 2021-01-28 21:39

I am trying to create a FreeMarker macro that can return the interpolation of a concatenation of a string and the input variable:

<#macro findValue var>
          


        
相关标签:
1条回答
  • 2021-01-28 22:05

    In FreeMarker, foo.bar is the same as foo["bar"], but inside the [] you can have an arbitrary expression that evaluates to a string. So the expression you are looking for is simply foo[var].

    BTW, what your macro tries to do is just ${foo[var]!bar[var]}

    0 讨论(0)
提交回复
热议问题