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

DESCRIPTION

94       CGI::Ex::Template is the original base for the code that is now
95       Template::Alloy.  Template::Alloy employed enough complexity and
96       featureset to warrant moving it out to a separate namespace.
97
98       CGI::Ex::Template is now a place holder subclass of Template::Alloy.
99       You can use CGI::Ex::Template as a standalone module - but it is
100       suggested that you use Template::Alloy directly instead.
101
102       For examples of usage, configuration, syntax, bugs, vmethods,
103       directives, etc please refer to the Template::Alloy documentation.
104

LICENSE

106       This module may be distributed under the same terms as Perl itself.
107

AUTHOR

109       Paul Seamons <perl at seamons dot com>
110
111
112
113perl v5.30.0                      2019-07-26              CGI::Ex::Template(3)
Impressum