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