Template-Alloy
view release on metacpan or search on metacpan
lib/Template/Alloy.pod view on Meta::CPAN
Note that you can use an exclamation point directly after the dollar
to make the variable silent. This is similar to how Velocity works.
=item START_TAG
Set a string or regular expression to use as the opening delimiter
for TT. Default is "[%".
You should be sure that the tag does not include grouping parens or
INTERPOLATE will not function properly.
=item STASH
Template::Alloy manages its own stash of variables. You can pass a
Template::Stash or Template::Stash::XS object, but Template::Alloy
will copy all of values out of the object into its own stash.
Template::Alloy won't use any of the methods of the passed STASH
object. The STASH option is only available when using the process
method.
=item STAT_TTL
Defaults to $STAT_TTL which defaults to 1. Represents time-to-live
seconds until a cached in memory document is compared to the file
system for modifications. Setting this number higher will allow for
fewer file system accesses. Setting it to a negative number will allow
for the file system to be checked every hit.
=item STREAM
Defaults to false. If set to true, generated template content will be
printed to the currently selected filehandle (default is STDOUT) as
soon as it is ready - there will be no buffering of the output.
The Stream role uses the Play role's directives (non-compiled_perl).
All directives and configuration work, except for the following
exceptions:
=over 4
=item CLEAR directive
Because the output is not buffered - the CLEAR directive would have no
effect. The CLEAR directive will throw an error when STREAM is on.
=item TRIM configuration
Because the output is not buffered - trim operations cannot be played
on the output buffers.
=item WRAPPER configuration/directive
The WRAPPER configuration and directive items effectively turn off
STREAM since the WRAPPERS are generated in reverse order and because
the content is inserted into the middle of the WRAPPERS. WRAPPERS
will still work, they just won't stream.
=item VARIOUS errors
Because the template is streaming, items that cause errors my result
in partially printed pages - since the error would occur part way
through the print.
=back
All output is printed directly to the currently selected filehandle
(defaults to STDOUT) via the CORE::print function. Any output
parameter passed to process or process_simple will be ignored.
If you would like the output to go to another handle, you will need to
select that handle, process the template, and re-select STDOUT.
=item STRICT
Defaults to false. If set to true, any undefined variable that is
encountered will cause the processing of the template to abort. This
can be caught with a TRY block. This can be useful for making sure
that the template only attempts to use variables that were correctly
initialized similar in spirit to Perl's "use strict."
When this occurs the strict_throw method is called.
See the STRICT_THROW configuration for additional options.
Similar functionality could be implemented using UNDEFINED_ANY.
The STRICT configuration item can be passed to new or it may also be
set during runtime using the CONFIG directive. Once set though it
cannot be disabled for the duration of the current template and sub
components. For example you could call [% CONFIG STRICT => 1 %] in
header.tt and strict mode would be enabled for the header.tt and any
sub templates processed by header.tt.
=item STRICT_THROW (not in TT)
Default undef. Can be set to a subroutine which will be called when
STRICT is set and an undefined variable is processed. It will be
passed the error type, error message, and a hashref of template
information containing the current component being processed, the
current outer template being processed, the identity reference for the
variable, and the stringified name of the identity. This override can
be used for filtering allowable elements.
my $ta = Template::Alloy->new({
STRICT => 1,
STRICT_THROW => sub {
my ($ta, $err_type, $msg, $args) = @_;
return if $args->{'component'} eq 'header.tt'
&& $args->{'template'} eq 'main.html'
&& $args->{'name'} eq 'foo.bar(1)'; # stringified identity name
$ta->throw($err_type, $msg); # all other undefined variables die
},
});
=item SYNTAX (not in TT)
Defaults to "cet". Indicates the syntax that will be used for parsing
included templates or eval'ed strings. You can use the CONFIG
( run in 0.657 second using v1.01-cache-2.11-cpan-5a3173703d6 )