]> git.decadent.org.uk Git - maypole.git/blob - lib/Maypole/View/TT.pm
Add constants; refactor View classes and tests to use them; refactor out
[maypole.git] / lib / Maypole / View / TT.pm
1 package Maypole::View::TT;
2 use base 'Maypole::View::Base';
3 use Maypole::Constants;
4 use Template;
5
6 sub template {
7     my ($self, $r) = @_;
8     my $template = Template->new({ INCLUDE_PATH => [ $self->paths($r) ]});
9     my $output;
10     if ($template->process($r->template, { $self->vars($r) }, \$output)) {
11         $r->{output} = $output;
12         return OK;
13     } else {
14         $r->{error} = $template->error;
15         return ERROR;
16     }
17 }
18
19 1;
20
21 =head1 NAME
22
23 Maypole::View::TT - A Template Toolkit view class for Maypole
24
25 =head1 SYNOPSIS
26
27     BeerDB->config->{view} = "Maypole::View::TT"; # The default anyway
28
29 =head1 DESCRIPTION
30
31 This is the default view class for Maypole; it uses the Template Toolkit
32 to fill in templates with the objects produced by Maypole's model classes.
33 Please see the Maypole manual, and in particular, the C<View> chapter,
34 for the template variables available and for a refresher on how template
35 components are resolved.
36
37 =head1 AUTHOR
38
39 Simon Cozens
40
41 =cut