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