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