Thursday, 5 September 2013

Freemarker - loop variables not surviving nested macro call

Freemarker - loop variables not surviving nested macro call

I have the following freemarker template:
[#local snippet ][#noparse]
[#assign out ]value: ${v}
[/#assign]
[/#noparse]
[/#local]
[#assign hook = snippet?interpret ]
...
[#macro trigger ]
[@hook /]
[/#macro]
...
[#list values as v ]
[@trigger ]
[/#list]
${out}
What it essentially does is defining a hooks to execute at a certain later
moment and a macro to trigger it's execution.
When I try to render this template, i get the following error:
The following has evaluated to null or missing:
==> v [in template "xxx.ftl->anonymous_interpreted" at line 1, column 17]
It might be interesting to note that the following:
[#list values as v ]
[@hook ]
[/#list]
is just working, i.e. rendering the template as I would expect, printing
value: xxx for each value in the list.
Does anybody know what is going wrong here?
Is there any way to make this work as expected?

No comments:

Post a Comment