global

Page Contents

Synopsis

<#global name=value>
or
<#global name1=value1 name2=value2 ... nameN=valueN>
or
<#global name>
  capture this
</#global>

Where:

Description

This directive is similar to assign, but the variable created will be visible in all namespaces, and will not be inside any namespace. Exactly as if you would create (or replace) a variable of the data-model. Hence, the variable is global. If a variable with the same name already exists in the data-model, it will be hidden by the variable created with this directive. If a variable with the same name already exists in the current namespace, that will hide the variable created with global directive.

For example, with <#global x = 1> you create a variable that is visible as x in all namespaces, unless another variable called x hides it (for example a variable what you have created as <#assign x = 2>). In this case, you can use special variable globals, like ${.globals.x}. Note that with globals you see all globally accessible variables; not only the variables that were created with global directive, but also the variables of the data-model.

Note for custom JSP tag users: The set of variables created with this directive corresponds to the JSP page-scope. This means, that if a custom JSP tag wants to get a page-scope attribute (page-scope bean), a variable with the same name in the current namespace will not hide it from the viewpoint of the JSP tag.

FreeMarker Manual -- For FreeMarker 2.3.22
HTML generated: 2015-02-28 21:34:03 GMT
Edited with XMLMind XML Editor
Here!