Template variables and code bindings

http://tem plate-toolkit.org/docs/manual/Variables.htm|

Template Variables

‘Scalar Values

Hash Array References

List References

Subroutines

Objects

Passing Parameters and Returning Values

Error Handling

Virtual Methods

Variable Interpolation

Local and Global Variables

Compile Time Constant Folding

Special Variables

template

component

loop

error

content

Compound Variables

A reference to a hash array may be passed as the second argument to the process() method, containing

definitions of template variables. The VARIABLES (a.k.a. PRE_DEFINE) option can also be used to pre-define

variables for all templates processed by the object.

my $tt = Template->new({

VARIABLES => {

version => 3.14,

release => 'Sahara',

}

ph;

my $vars = {

serial_no => 271828,

35

$tt->process('myfile', $vars);

myfile template:

This is version [% version %] ([% release %]).

Serial number: [% serial_no %] i

Generated Output: