Dear FreeMarker team,

First I would like to thank you for creating such a nice template engine, I
personally liked it very much :-)

I need your help in an issue,

While using <#nested>, the variable I defined using assign is not
accessible in nested code.

Here is the more details

1.) I have a macro file having Widgets.ftl

{code}

<#macro getName>
    <#assign name = "FreeMarker World"/>
    <#nested>
</#macro>

{code}

2.) I have included the above file in another file using <#import>

{code}

<#import "Widgets.ftl" as widget>
<@widget.getName>
    Hi ${name!}
</@widget.getName>

{code}

Expected output - Hi FreeMarker World
Actual output - Hi


Here the value of 'name' variable is not setting properly if assign is used.
But when I set it using global, everything work as expected.

{code}
<#global name = "FreeMarker World"/>
{code}

The similar types of macros will be heavily used in my application and
setting it at global level will cause performance and memory issue. So, I
want to set value of variable using assign.

Please let me know if I am missing anything.
Thanks again for your time and contribution.

- Best Regards,
Swapnil M Mane

Reply via email to