.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Dancer2::Template::Implementation::ForkedTiny 3pm" .TH Dancer2::Template::Implementation::ForkedTiny 3pm "2023-12-15" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Dancer2::Template::Implementation::ForkedTiny \- Dancer2 own implementation of Template::Tiny .SH "VERSION" .IX Header "VERSION" version 1.1.0 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& my $template = Dancer2::Template::Implementation::ForkedTiny\->new( \& TRIM => 1, \& ); \& \& # Print the template results to STDOUT \& $template\->process( <<\*(AqEND_TEMPLATE\*(Aq, { foo => \*(AqWorld\*(Aq } ); \& Hello [% foo %]! \& END_TEMPLATE .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBDancer2::Template::Implementation::ForkedTiny\fR is a reimplementation of a subset of the functionality from Template Toolkit in as few lines of code as possible. .PP 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. .PP For the subset of functionality it implements, it has fully-compatible template and stash \s-1API.\s0 All templates used with \fBDancer2::Template::Implementation::ForkedTiny\fR should be able to be transparently upgraded to full Template Toolkit. .PP Unlike Template Toolkit, \fBDancer2::Template::Implementation::ForkedTiny\fR will process templates without a compile phase (but despite this is still quicker, owing to heavy use of the Perl regular expression engine. .SS "\s-1SUPPORTED USAGE\s0" .IX Subsection "SUPPORTED USAGE" By default, the \f(CW\*(C`[% %]\*(C'\fR tag style is used. You can change the start tag and end tag by specifying them at object creation : .PP .Vb 4 \& my $template = Dancer2::Template::Implementation::ForkedTiny\->new( \& start_tag => \*(Aq<%\*(Aq, \& end_tag => \*(Aq%>, \& ); .Ve .PP In the rest of the documentation, \f(CW\*(C`[% %]\*(C'\fR will be used, but it can be of course your specified start / end tags. .PP Both the \f(CW\*(C`[%+ +%]\*(C'\fR style explicit whitespace and the \f(CW\*(C`[%\- \-%]\*(C'\fR style explicit chomp \fBare\fR support, although the \f(CW\*(C`[%+ +%]\*(C'\fR version is unneeded in practice as \fBDancer2::Template::Implementation::ForkedTiny\fR does not support default-enabled \f(CW\*(C`PRE_CHOMP\*(C'\fR or \f(CW\*(C`POST_CHOMP\*(C'\fR. .PP Variable expressions in the form \f(CW\*(C`[% foo.bar.baz %]\*(C'\fR \fBare\fR supported. .PP Appropriate simple behaviours for \f(CW\*(C`ARRAY\*(C'\fR references, \f(CW\*(C`HASH\*(C'\fR references and objects are supported. \*(L"VMethods\*(R" such as [% array.length %] are \fBnot\fR supported at this time. .PP If the resulting expression is a CodeRef, it'll be evaluated. .PP \&\f(CW\*(C`IF\*(C'\fR, \f(CW\*(C`ELSE\*(C'\fR and \f(CW\*(C`UNLESS\*(C'\fR conditional blocks \fBare\fR supported, but only with simple \f(CW\*(C`[% foo.bar.baz %]\*(C'\fR conditions. .PP Support for looping (or rather iteration) is available in simple \&\f(CW\*(C`[% FOREACH item IN list %]\*(C'\fR form \fBis\fR supported. Other loop structures are \&\fBnot\fR supported. Because support for arbitrary or infinite looping is not available, \fBDancer2::Template::Implementation::ForkedTiny\fR templates are not turing complete. This is intentional. .PP All of the four supported control structures \f(CW\*(C`IF\*(C'\fR/\f(CW\*(C`ELSE\*(C'\fR/\f(CW\*(C`UNLESS\*(C'\fR/\f(CW\*(C`FOREACH\*(C'\fR can be nested to arbitrary depth. .PP The treatment of \f(CW\*(C`_private\*(C'\fR hash and method keys is compatible with Template Toolkit, returning null or false rather than the actual content of the hash key or method. .PP Anything beyond the above is currently out of scope. .SH "NAME" Dancer2::Template::Implementation::ForkedTiny \- Template Toolkit reimplemented in as little code as possible, forked from Template::Tiny .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 3 \& my $template = Dancer2::Template::Implementation::ForkedTiny\->new( \& TRIM => 1, \& ); .Ve .PP The \f(CW\*(C`new\*(C'\fR constructor is provided for compatibility with Template Toolkit. .PP The only parameter it currently supports is \f(CW\*(C`TRIM\*(C'\fR (which removes leading and trailing whitespace from processed templates). .PP Additional parameters can be provided without error, but will be ignored. .SS "process" .IX Subsection "process" .Vb 2 \& # DEPRECATED: Return template results (emits a warning) \& my $text = $template\->process( \e$input, $vars ); \& \& # Print template results to STDOUT \& $template\->process( \e$input, $vars ); \& \& # Generate template results into a variable \& my $output = \*(Aq\*(Aq; \& $template\->process( \e$input, $vars, \e$output ); .Ve .PP The \f(CW\*(C`process\*(C'\fR method is called to process a template. .PP 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. .PP If a third parameter is provided, it must be a scalar reference to be populated with the output of the template. .PP For a limited amount of time, the old deprecated interface will continue to be supported. If \f(CW\*(C`process\*(C'\fR is called without a third parameter, and in scalar or list contest, the template results will be returned to the caller. .PP If \f(CW\*(C`process\*(C'\fR is called without a third parameter, and in void context, the template results will be \f(CW\*(C`print()\*(C'\fRed to the currently selected file handle (probably \f(CW\*(C`STDOUT\*(C'\fR) for compatibility with Template. .SH "SUPPORT" .IX Header "SUPPORT" Bugs should be reported via the \s-1CPAN\s0 bug tracker at .PP .PP For other issues, or commercial enhancement or support, contact the author. .SH "AUTHOR" .IX Header "AUTHOR" Adam Kennedy .PP Forked and improved by Damien Krotkine .SH "SEE ALSO" .IX Header "SEE ALSO" Config::Tiny, CSS::Tiny, YAML::Tiny .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2009 \- 2011 Adam Kennedy. Copyright 2012 Damien Krotkine. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP The full text of the license can be found in the \&\s-1LICENSE\s0 file included with this module. .SH "AUTHOR" .IX Header "AUTHOR" Dancer Core Developers .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2023 by Alexis Sukrieh. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.