Act provides a set of classes that encapsulate Template Toolkit's functionality. The base class is Act::Template, a subclass of Template to which it adds:
A template's INCLUDE_PATH is the list of directories where TT searches
for template files.
When a new template is created (Act::Template->new
), the INCLUDE_PATH
is set according to current configuration and request: first any conference
specific paths, if the current request is within a given conference, then
the global template directories. This allows overriding global templates
on a case by case basis.
Act::Template->new
acts as an object factory: it maintains an internal
cache of template objects. This avoids the overhead associated with template
object creation and leverages TT's internal compiled templates cache.
Multiple versions of the same text can be included in a given template, using an XML-like syntax:
<t>...</t<>
surrounds a multilingual text section.
<xx>...</xx>
surrounds a particular language version, where xx
is a language
code. Here's an example:
<t><fr>Bonjour</fr><en>Hello</en></t>
These language sections are parsed when TT compiles the template, and therefore have no impact on TT's compiled templates cache. At request time, Act::Template will process the appropriate language section according to the current request language.
This is a convenience method. $template->variables()
will accumulate template
variable settings until template processing time.
When no output argument is provided, Act::Template::process
outputs to
$Request{r}
, which if in a web context will be the client's browser.
Thus in the general case process() is called with a single argument, the
template's filename.
Act::Template::HTML is a subclass of Act::Template which adds the following features:
automatic HTML escaping of template variables: &, <, > are converted to HTML entities & < and >. This works on nested data structures as well.