NAME

Kelp::Module::Template - Template processing for Kelp applications

SYNOPSIS

First ...

# conf/config.pl
{
    modules => ['Template'],
    modules_init => {
        Template => { ... }
    }
};

Then ...

# lib/MyApp.pm
sub some_route {
    my $self = shift;
    $self->template('some_template', { bar => 'foo' });
}

DESCRIPTION

This module provides interface for using templates in a Kelp web application. It uses Template by default, but it could be easily subclassed to use anything else.

REGISTERED METHODS

template

template($filename, \%vars)

Renders a file using the currently loaded template engine. If the file doesn't have an extension, the one specified in "ext" will be assigned to it.

ATTRIBUTES

ext

The default extension of the template files. This module sets this attribute to tt, so

$self->template( 'home' );

will look for home.tt.

SUBCLASSING

To use a different template engine, you can subclass this module. You only need to override ext to set the new file extension. Then register the template method with the following arguments: template( $filename, \%vars ).