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

VERSION

10       version 2.50
11

SYNOPSIS

13   Template::Toolkit style usage
14           my $t = Template::Alloy->new(
15               INCLUDE_PATH => ['/path/to/templates'],
16           );
17
18           my $swap = {
19               key1 => 'val1',
20               key2 => 'val2',
21               code => sub { 42 },
22               hash => {a => 'b'},
23           };
24
25           # print to STDOUT
26           $t->process('my/template.tt', $swap)
27               || die $t->error;
28
29           # process into a variable
30           my $out = '';
31           $t->process('my/template.tt', $swap, \$out);
32
33           ### Alloy uses the same syntax and configuration as Template::Toolkit
34
35   HTML::Template::Expr style usage
36           my $t = Template::Alloy->new(
37               filename => 'my/template.ht',
38               path     => ['/path/to/templates'],
39           );
40
41           my $swap = {
42               key1 => 'val1',
43               key2 => 'val2',
44               code => sub { 42 },
45               hash => {a => 'b'},
46           };
47
48           $t->param($swap);
49
50           # print to STDOUT (errors die)
51           $t->output(print_to => \*STDOUT);
52
53           # process into a variable
54           my $out = $t->output;
55
56           ### Alloy can also use the same syntax and configuration as HTML::Template
57
58   Text::Tmpl style usage
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
79           ### Alloy uses the same syntax and configuration as Text::Tmpl
80
81   Velocity (VTL) style usage
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
98       Template::Alloy.  Template::Alloy employed enough complexity and
99       featureset 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
103       suggested that you use Template::Alloy directly instead.
104
105       For examples of usage, configuration, syntax, bugs, vmethods,
106       directives, 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.32.0                      2020-07-28              CGI::Ex::Template(3)
Impressum