]> git.decadent.org.uk Git - maypole.git/blob - lib/Maypole/View/Mason.pm
oops, missed changes file.
[maypole.git] / lib / Maypole / View / Mason.pm
1 package Maypole::View::Mason;
2 use base 'Maypole::View::Base';
3 use HTML::Mason;
4 use Maypole::Constants;
5
6 sub template {
7     my ($self, $r) = @_;
8     my $label = "path0";
9     my $output;
10     my $mason = HTML::Mason::Interp->new(
11         comproot => [ map { [ $label++ => $_ ] } $self->paths($t) ],
12         output_method => \$output,
13         error_mode => "output" # Saves us having to handle them...
14     );
15     $mason->exec($r->template, $self->vars($r))
16     $r->{output} = $output;
17     return OK;
18 }
19
20 1;
21
22 =head1 NAME
23
24 Maypole::View::Mason - A HTML::Mason view class for Maypole
25
26 =head1 SYNOPSIS
27
28    BeerDB->config->{view} = "Maypole::View::Mason"; 
29
30 And then:
31
32     <%args>
33         @breweries
34     </%args>
35
36     % for my $brewery (@breweries) {
37         ...
38         <TD><% $brewery->name %></TD>
39     % }
40     ...
41
42 =head1 DESCRIPTION
43
44 This class allows you to use C<HTML::Mason> components for your Maypole
45 templates. It provides precisely the same path searching and template
46 variables as the Template Toolkit view class, although you will need
47 to produce your own set of templates as the factory-supplied templates
48 are, of course, Template Toolkit ones. 
49
50 Please see the Maypole manual, and in particular, the C<View> chapter,
51 for the template variables available and for a refresher on how template
52 components are resolved.
53
54 =head1 AUTHOR
55
56 Simon Cozens
57
58 =head1 THANKS
59
60 This module was made possible thanks to a Perl Foundation grant.
61
62 =cut