]> git.decadent.org.uk Git - maypole.git/blob - lib/Maypole/Components.pm
Fixed mime type setting, fixed errors in revision 445, folded in Maypole::Component...
[maypole.git] / lib / Maypole / Components.pm
1 package Maypole::Components;
2 use base 'Maypole';
3 use strict;
4 use warnings;
5 use URI; 
6 use URI::QueryParam;
7
8 sub new {
9     my ($class,$r, $path) = @_;
10     my $self = bless { config => $r->config, parent => $r }, $class;
11 }
12
13 sub handler {
14     my $self = shift;
15     my $url = URI->new($path);
16     $self->{path} = $url->path;
17     $self->parse_path;
18     $self->{query} = $url->query_form_hash;
19     $self->handler_guts;
20     return $self->{output};
21 }
22
23 sub get_template_root { shift->{parent}->get_template_root }
24 sub view_object { shift->{parent}->view_object }
25
26 1;
27 __END__
28
29 =head1 NAME
30
31 Maypole::Components - Run Maypole sub-requests as components
32
33 =head1 SYNOPSIS
34
35     package BeerDB;
36     use base qw(Maypole);
37
38
39
40     [% request.component("/beer/view_as_component/20") %]
41
42 =head1 DESCRIPTION
43
44 This subclass of Maypole allows you to integrate the results of a Maypole
45 request into an existing request. You'll need to set up actions and templates
46 which return fragments of HTML rather than entire pages, but once you've
47 done that, you can use the C<component> method of the Maypole request object
48 to call those actions. You may pass a query string in the usual URL style.
49 You should not fully qualify the Maypole URLs.
50
51 =head1 SEE ALSO
52
53 http://maypole.perl.org/
54
55 =head1 AUTHOR
56
57 Simon Cozens, E<lt>simon@cpan.orgE<gt>
58
59 =head1 COPYRIGHT AND LICENSE
60
61 Copyright 2004 by Simon Cozens
62
63 =cut