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