1CGI::Ex::Template(3)  User Contributed Perl Documentation CGI::Ex::Template(3)
2
3
4

NAME

6       CGI::Ex::Template - Template::Alloy based TT2/TT3/HT/HTE/Tmpl/Velocity
7       engine.
8

SYNOPSIS

10       Template::Toolkit style usage
11
12           my $t = Template::Alloy->new(
13               INCLUDE_PATH => ['/path/to/templates'],
14           );
15
16           my $swap = {
17               key1 => 'val1',
18               key2 => 'val2',
19               code => sub { 42 },
20               hash => {a => 'b'},
21           };
22
23           # print to STDOUT
24           $t->process('my/template.tt', $swap)
25               ⎪⎪ die $t->error;
26
27           # process into a variable
28           my $out = '';
29           $t->process('my/template.tt', $swap, \$out);
30
31           ### Alloy uses the same syntax and configuration as Template::Toolkit
32
33       HTML::Template::Expr style usage
34
35           my $t = Template::Alloy->new(
36               filename => 'my/template.ht',
37               path     => ['/path/to/templates'],
38           );
39
40           my $swap = {
41               key1 => 'val1',
42               key2 => 'val2',
43               code => sub { 42 },
44               hash => {a => 'b'},
45           };
46
47           $t->param($swap);
48
49           # print to STDOUT (errors die)
50           $t->output(print_to => \*STDOUT);
51
52           # process into a variable
53           my $out = $t->output;
54
55           ### Alloy can also use the same syntax and configuration as HTML::Template
56
57       Text::Tmpl style usage
58
59           my $t = Template::Alloy->new;
60
61           my $swap = {
62               key1 => 'val1',
63               key2 => 'val2',
64               code => sub { 42 },
65               hash => {a => 'b'},
66           };
67
68           $t->set_delimiters('#[', ']#');
69           $t->set_strip(0);
70           $t->set_values($swap);
71           $t->set_dir('/path/to/templates');
72
73           my $out = $t->parse_file('my/template.tmpl');
74
75           my $str = "Foo #[echo $key1]# Bar";
76           my $out = $t->parse_string($str);
77
78           ### Alloy uses the same syntax and configuration as Text::Tmpl
79
80       Velocity (VTL) style usage
81
82           my $t = Template::Alloy->new;
83
84           my $swap = {
85               key1 => 'val1',
86               key2 => 'val2',
87               code => sub { 42 },
88               hash => {a => 'b'},
89           };
90
91           my $out = $t->merge('my/template.vtl', $swap);
92
93           my $str = "#set($foo 1 + 3) ($foo) ($bar) ($!baz)";
94           my $out = $t->merge(\$str, $swap);
95

DESCRIPTION

97       CGI::Ex::Template is the original base for the code that is now Tem‐
98       plate::Alloy.  Template::Alloy employed enough complexity and feature‐
99       set to warrant moving it out to a separate namespace.
100
101       CGI::Ex::Template is now a place holder subclass of Template::Alloy.
102       You can use CGI::Ex::Template as a standalone module - but it is sug‐
103       gested that you use Template::Alloy directly instead.
104
105       For examples of usage, configuration, syntax, bugs, vmethods, direc‐
106       tives, etc please refer to the Template::Alloy documentation.
107

LICENSE

109       This module may be distributed under the same terms as Perl itself.
110

AUTHOR

112       Paul Seamons <perl at seamons dot com>
113
114
115
116perl v5.8.8                       2007-10-18              CGI::Ex::Template(3)
Impressum