Zbigniew Łukasiak > WebNano-0.007 > WebNano::Renderer::TTiny

Download:
WebNano-0.007.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.007   Source  

NAME ^

WebNano::Renderer::TTiny - Dynamic search paths for Template::Tiny

VERSION ^

version 0.007

SYNOPSIS ^

in MyApp.pm:

    $self->renderer( 
        WebNano::Renderer::TTiny->new( root => 't/data/templates' )
    );

in MyApp::Controller:

    return $self->render( template => 'some_template.tt', some_var => 'some_value );

DESCRIPTION ^

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:

template - the name of the template file
c - the controller

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 template/SubController and 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 INCLUDE_PATH.

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 TEMPLATE_EXTENSION attribute.

ATTRIBUTES and METHODS ^

render

INCLUDE_PATH

Static list of template search directories.

root

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.

TEMPLATE_EXTENSION

Postfix added to action name to form the template name ( for example 'edit.tt' from action 'edit' and TEMPLATE_EXTENSION 'tt' ).

AUTHOR ^

Zbigniew Lukasiak <zby@cpan.org>

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2010 by Zbigniew Lukasiak <zby@cpan.org>.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
syntax highlighting: