| Verby-Action-Template documentation | Contained in the Verby-Action-Template distribution. |
Verby::Action::Template - Action to process Template Toolkit files
use Verby::Action::Template;
This Action, given a set of template data, will process Template Toolkit files and return their output.
Run the template.
Construct the tempalte variables.
Returns true if $c->output is a plain string a file by that name exists.
A hash reference containing the default options for the TT constructor. Has DEBUG_UNDEF enabled, and ABSOLUTE set to true.
A lazy field, whose default value is defined as
Template->new( $self->template_options ).
None that we are aware of. Of course, if you find a bug, let us know, and we will be sure to fix it.
We use Devel::Cover to test the code coverage of the tests, please refer to COVERAGE section of the Verby module for more information.
Yuval Kogman, <nothingmuch@woobling.org>
Copyright 2005-2008 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Verby-Action-Template documentation | Contained in the Verby-Action-Template distribution. |
#!/usr/bin/perl package Verby::Action::Template; use Moose; with qw/Verby::Action/; our $VERSION = "0.04"; use Template; use Template::Constants qw( :debug ); has template_options => ( isa => "HashRef", is => "rw", auto_deref => 1, default => sub { return { ABSOLUTE => 1, DEBUG => DEBUG_UNDEF, }}, ); has template_object => ( isa => "Object", is => "rw", default => sub { my $self = shift; Template->new( $self->template_options ), }, ); sub do { my ( $self, $c ) = @_; my $output = $c->output; my $template = $c->template; $c->logger->info("templating '$template' into $output"); my $t = $self->template_object; $t->process($template, $self->template_vars($c), $output) || $c->logger->logdie("couldn't process template: " . $t->error); } sub template_vars { my ( $self, $c ) = @_; return { c => $c }; } sub verify { my ( $self, $c ) = @_; my $output = $c->output; (defined($output) and not ref($output)) ? -e $output : undef; } __PACKAGE__ __END__