For instance:
<#assign foo="foo"/>
<#local bar="bar"/>
When should one be used instead of the other
#local
creates or replaces a variable that lives in the scope of the ongoing macro or function call, and thus is used inside a #macro
or #function
.
#assign
creates or replaces a variable in the current namespace (or in the explicitly designated namespace via in somenamespace
). If you don't use multiple namespaces (ie., you don't use #import
) then you can think of them as global variables.
See also:
Kinds of variables: http://freemarker.org/docs/dgui_misc_var.html
Namespaces: http://freemarker.org/docs/dgui_misc_namespace.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With