[% cet %]
- [% cet.dump_parse('1 + 2').replace('\s+', ' ') %]
+ [% cet.dump_parse_expr('1 + 2').replace('\s+', ' ') %]
Would print something like:
=item fmt
[% item.fmt('%d') %]
+ [% item.fmt('%6s') %]
+ [% item.fmt('%*s', 6) %]
Similar to format. Returns a string formatted with the passed pattern. Default pattern is %s.
=item format
- [% item.format('%d') %] Print the string out in the specified format. It is similar to
- the "as" virtual method, except that the item is split on newline and each line is
- processed separately.
+ [% item.format('%d') %]
+ [% item.format('%6s') %]
+ [% item.format('%*s', 6) %]
+
+Print the string out in the specified format. It is similar to
+the "fmt" virtual method, except that the item is split on newline and each line is
+processed separately.
=item hash
=item fmt
[% mylist.fmt('%s', ', ') %]
+ [% mylist.fmt('%6s', ', ') %]
+ [% mylist.fmt('%*s', ', ', 6) %]
Passed a pattern and an string to join on. Returns a string of the values of the list
formatted with the passed pattern and joined with the passed string.
=item fmt
[% myhash.fmt('%s => %s', "\n") %]
+ [% myhash.fmt('%4s => %5s', "\n") %]
+ [% myhash.fmt('%*s => %*s', "\n", 4, 5) %]
Passed a pattern and an string to join on. Returns a string of the key/value pairs
of the hash formatted with the passed pattern and joined with the passed string.
# The LOAD_PERL directive should be set to 1
[% USE cet = CGI::Ex::Template %]
- [%~ cet.dump_parse('2 * 3').replace('\s+', ' ') %]
+ [%~ cet.dump_parse_expr('2 * 3').replace('\s+', ' ') %]
Would print:
In order to not conflict with SET, FOREACH and other operations, this
operator is only available in parenthesis.
- [% a = 2 %][% a += 3 %] --- [% a %] => --- 5 # is was handled by SET
+ [% a = 2 %][% a += 3 %] --- [% a %] => --- 5 # is handled by SET
[% a = 2 %][% (a += 3) %] --- [% a %] => 5 --- 5
=item C<=>
to not conflict with SET, FOREACH and other operations, this operator is only
available in parenthesis. Returns the value of the righthand side.
- [% a = 1 %] --- [% a %] => --- 1 # is was handled by SET
+ [% a = 1 %] --- [% a %] => --- 1 # is handled by SET
[% (a = 1) %] --- [% a %] => 1 --- 1
=item C<not NOT>
Default value is Template::Plugin. The base module namespace
that template plugins will be looked for. See the USE directive
-for more information.
+for more information. May be either a single namespace, or an arrayref
+of namespaces.
=item POST_CHOMP
The following perl can be typed at the command line to view the parsed variable tree:
- perl -e 'use CGI::Ex::Template; print CGI::Ex::Template::dump_parse("foo.bar + 2")."\n"'
+ perl -e 'use CGI::Ex::Template; print CGI::Ex::Template::dump_parse_expr("foo.bar + 2")."\n"'
Also the following can be included in a template to view the output in a template:
[% USE cet = CGI::Ex::Template %]
- [%~ cet.dump_parse('foo.bar + 2').replace('\s+', ' ') %]
+ [%~ cet.dump_parse_expr('foo.bar + 2').replace('\s+', ' ') %]
=head1 SEMI PUBLIC METHODS
=item C<dump_parse>
+This method allows for returning a Data::Dumper dump of a parsed template. It is mainly used for testing.
+
+=item C<dump_parse_expr>
+
This method allows for returning a Data::Dumper dump of a parsed variable. It is mainly used for testing.
=item C<exception>
Methods by these names implement virtual methods that are more than one line.
-=item C<weak_copy>
-
-Used to create a weak reference to self to avoid circular references. (this
-is needed by macros)
-
=back