WebNano::Renderer::TTiny - Dynamic search paths for Template::Tiny
$self->renderer( WebNano::Renderer::TTiny->new( root => 't/data/templates' ) );
return $self->render( template => 'some_template.tt', some_var => 'some_value );
This is a wrapper around Template::Tiny - 'Template Toolkit reimplemented in as little code as possible'.
The only public method here is render - it expects as input a hash with the following data:
The template is then looked for in the directories in
INCLUDE_PATH and in directories constructed dynamically from the paths in
root and the controller name. For example if 'root' contains
[ 'template', 'additional_templates' ] and the controller name is
MyApp::Controller::SubController then the template will be looked for in
additional_templates/SubController. This mechanism is designed so that it is possible for a way of subclassing templates along with subclassing controllers. If this is too complicated - you can provide no value for the
root attribute and use only
When the template is found - the
process method on the internal
Template::Tiny object is called. A reference to the whole hash passed to
render is passed to the
process call - so that all the values are available in the template itself.
If no template name is passed - then it is guessed from the name of the controller method that called
render (this is done using caller) and the
Static list of template search directories.
List of directories that are dynamically concatenated with controller names to form a dynamic search list of template directories.
You can use INCLUDE_PATH or root or both.
Postfix added to action name to form the template name ( for example 'edit.tt' from action 'edit' and TEMPLATE_EXTENSION 'tt' ).
Zbigniew Lukasiak <firstname.lastname@example.org>
This software is Copyright (c) 2010 by Zbigniew Lukasiak <email@example.com>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)