=pod
=encoding UTF-8
=head1 NAME
Template::Tiny - Template Toolkit reimplemented in as little code as possible
=head1 VERSION
version 1.14
=head1 SYNOPSIS
my $template = Template::Tiny->new( TRIM => 1, );
$template->process( <<'END_TEMPLATE', { foo => 'World' } ); Hello [% foo %]! END_TEMPLATE
=head1 DESCRIPTION
BTemplate::Tiny is a reimplementation of a subset of the functionality from L Toolkit in as few lines of code as possible.
It is intended for use in light-usage, low-memory, or low-cpu templating situations, where you may need to upgrade to the full feature set in the future, or if you want the retain the familiarity of TT-style templates.
For the subset of functionality it implements, it has fully-compatible template and stash API. All templates used with BTemplate::Tiny should be able to be transparently upgraded to full Template Toolkit.
Unlike Template Toolkit, BTemplate::Tiny will process templates without a compile phase (but despite this is still quicker, owing to heavy use of the Perl regular expression engine.
=head2 SUPPORTED USAGE
Only the default C<[% %]> tag style is supported.
Both the C<[%+ +%]> style explicit whitespace and the C<[%- -%]> style explicit chomp B support, although the C<[%+ +%]> version is unneeded in practice as BTemplate::Tiny does not support default-enabled C<PRE_CHOMP> or C<POST_CHOMP>.
Variable expressions in the form C<[% foo.bar.baz %]> B supported.
Appropriate simple behaviours for C references, C references and objects are supported. "VMethods" such as [% array.length %] are B supported at this time.
C, C and C conditional blocks B supported, but only with simple C<[% foo.bar.baz %]> conditions.
Support for looping (or rather iteration) is available in simple C<[% FOREACH item IN list %]> form B supported. Other loop structures are B supported. Because support for arbitrary or infinite looping is not available, BTemplate::Tiny templates are not turing complete. This is intentional.
All of the four supported control structures C/C/C/C can be nested to arbitrary depth.
The treatment of C<_private> hash and method keys is compatible with L Toolkit, returning null or false rather than the actual content of the hash key or method.
Anything beyond the above is currently out of scope.
=head1 METHODS
=head2 new
my $template = Template::Tiny->new( TRIM => 1, );
The C constructor is provided for compatibility with Template Toolkit.
The only parameter it currently supports is C (which removes leading and trailing whitespace from processed templates).
Additional parameters can be provided without error, but will be ignored.
=head2 process
my $text = $template->process( $input, $vars );
$template->process( $input, $vars );
my $output = ''; $template->process( $input, $vars, $output );
The C method is called to process a template.
The first parameter is a reference to a text string containing the template text. A reference to a hash may be passed as the second parameter containing definitions of template variables.
If a third parameter is provided, it must be a scalar reference to be populated with the output of the template.
For a limited amount of time, the old deprecated interface will continue to be supported. If C is called without a third parameter, and in scalar or list contest, the template results will be returned to the caller.
If C is called without a third parameter, and in void context, the template results will be C<print()>ed to the currently selected file handle (probably C) for compatibility with L.
=head1 SEE ALSO
LTemplate::Tiny::Strict, LConfig::Tiny, LCSS::Tiny, LYAML::Tiny
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Template-Tiny> (or L<[email protected]|mailto:[email protected]>).
=head1 AUTHOR
Adam Kennedy [email protected]
=head1 CONTRIBUTORS
=for stopwords Adam Kennedy Karen Etheridge Alexandr Ciornii Matt S Trout
=over 4
=item *
Adam Kennedy [email protected]
=item *
Karen Etheridge [email protected]
=item *
Alexandr Ciornii [email protected]
=item *
Matt S Trout [email protected]
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Adam Kennedy.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
=cut