TALES root variables
As described, every TALES path:
expression must begin
with a variable from the current TALES context. Variables may be added to the context one of a number of
mechanisms, such as by using tal:define
and/or
tal:repeat
attributes. TALES itself though provides a number of
variables of its own - these are the root variables, available to all views:
When using ZPT-Sharp as an ASP.NET MVC ViewEngine, a few additional root variables are provided by the ViewEngine itself.
nothing
The root variable nothing
provides a null
value. It is a convenient way of getting a
null reference.
default
The default
root variable provides a special value which indicates that the expression result
should indicate the action is to be cancelled.
It is a minimal object implementing
CSF.Zpt.Rendering.IActionCanceller
which always returns true
for the method
ShouldCancelAction()
.
options
options
provides access to the keyword options provided to the ZPT rendering
process. Keyword options are an IDictionary<string,string>
of key/value pairs. For MVC
views, this is generally an empty collection as they have no meaning in that environment.
In other rendering scenarios though, it allows the calling process to set a number of variables externally, in order to provide values to the renderer. For example, the command-line page renderer allows setting of keyword options via an optional parameter.
repeat
The repeat
root variable provides access to the special
repeat variables which expose information about the current iteration.
Each repeat variable is available as a child of the repeat root-variable. They are named identically to the
local variable created by the tal:repeat
attribute.
attrs
The root variable attrs
provides access to the original HTML/XML attributes of the element upon
which the TALES expression appears. These original attributes are exposed with their values before any
manipulation has been performed by TAL.