| Fuse-Template documentation | Contained in the Fuse-Template distribution. |
Fuse::Template::TT - Read template files
Holds a hash ref with the variables which is available in the template.
Holds an array ref with paths to where Template::Toolkit will look for templates.
$text = $self->render($vfile);
Will return the output from a processed template. The $vfile points
to a template relative to one of the paths. It cannot start with "/".
$text will hold the error message if templat toolkit fail to render
the template.
See Template.
See Template.
See Fuse::Template.
| Fuse-Template documentation | Contained in the Fuse-Template distribution. |
package Fuse::Template::TT;
use Moose; use Template;
has vars => ( is => 'ro', isa => 'HashRef', default => sub { {} }, );
has paths => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has _template => ( is => 'ro', isa => 'Object', lazy_build => 1, handles => [qw/process error/], ); sub _build__template { return Template->new( INCLUDE_PATH => $_[0]->paths, EVAL_PERL => 0, TEMPLATE_EXTENSION => 'tt', ); }
sub render { my $self = shift; my $vfile = shift; my $text; $self->process($vfile, $self->vars, \$text); return $text ? $text : $self->error; }
1;