|
NAMETemplate::Toolkit::Simple - A Simple Interface to Template Toolkit SYNOPSIS use Template::Toolkit::Simple;
print tt
->path(['./', 'template/'])
->data('values.yaml')
->post_chomp
->render('foo.tt');
or from the command line: tt-render --path=./:template/ --data=values.yaml --post-chomp foo.tt DESCRIPTIONTemplate Toolkit is the best Perl template framework. The only problem with it is that using it for simple stuff is a little bit cumbersome. Also there is no good utility for using it from the command line. This module is a simple wrapper around Template Toolkit. It exports a function called "tt" which returns a new Template::Toolkit::Simple object. The object supports method calls for setting all the Template Toolkit options. This module also installs a program called "tt-render" which you can use from the command line to render templates with all the power of the Perl object. All of the object methods become command line arguments in the command line version. COMMAND LINE USAGEThis command renders the named file and prints the output to STDOUT. If an error occurs, it is printed to STDERR. tt-render [template-options] file-name TEMPLATE PATHWhen using Template::Toolkit::Simple or "tt-render", the most common parameters you will use are the main template file name and the directory of supporting templates. As a convenience, you can specify these together. This: tt->render('foo//bar/baz.tt');
> tt-render foo//bar/baz.tt # command line version
is the same as: tt->include_path('foo/')->render('bar/baz.tt');
> tt-render --include_path=foo/ bar/baz.tt # command line version
Just use a double slash to separate the path from the template. This is extra handy on the command line, because (at least in Bash) tab completion still works after you specify the '//'. EXPORTED SUBROUTINES
METHODSThis section describes the methods that are not option setting methods. Those methods are described below.
OPTION METHODSAll of the Template Toolkit options are available as methods to Template::Toolkit::Simple objects, and also as command line options to the "tt- render" command. For example, the "POST_CHOMP" options is available in the following ways: tt->post_chomp # turn POST_CHOMP on
tt->post_chomp(1) # turn POST_CHOMP on
tt->post_chomp(0) # turn POST_CHOMP off
--post_chomp # turn POST_CHOMP on
--post-chomp # same. use - instead of _
--post_chomp=1 # turn POST_CHOMP on
--post_chomp=0 # turn POST_CHOMP off
If the method functionality is not explained below, please refer to Template.
AUTHORIngy döt Net <ingy@cpan.org> COPYRIGHT AND LICENSECopyright 2008-2014. Ingy döt Net. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html>
|