=pod =for comment DO NOT EDIT. This Pod was generated by Swim v0.1.31. See http://github.com/ingydotnet/swim-pm#readme =encoding utf8 =head1 NAME Template::Toolkit::Simple - A Simple Interface to Template Toolkit =for html template-toolkit-simple-pm template-toolkit-simple-pm =head1 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 =head1 DESCRIPTION Template 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 C 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 C 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. =head1 COMMAND LINE USAGE This 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 =head1 TEMPLATE PATH When using Template::Toolkit::Simple or C, 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 '//'. =head1 EXPORTED SUBROUTINES =over =item tt Simply returns a new Template::Toolkit::Simple object. This is Simple sugar for: Template::Toolkit::Simple->new(); It takes no parameters. =back =head1 METHODS This section describes the methods that are not option setting methods. Those methods are described below. =over =item new() Return a new Template::Toolkit::Simple object. Takes no parameters. =item render($template, $data); This is the method that actually renders the template. It is similar to the Template Toolkit C method, except that it actually returns the template result as a string. It returns undef if an error occurs. The C<$data> field is optional and can be set with the C method. If you need more control, see the process command below: =item process($template, $data, $output, %options); This command is simply a proxy to the Template Toolkit C command. All the parameters you give it are passed to the real C command and the result is returned. See L