handler_guts to allow subcomponent stuff.
git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@116
48953598-375a-da11-a14b-
00016c27c3ee
use File::Spec;
use UNIVERSAL::moniker;
use strict;
use File::Spec;
use UNIVERSAL::moniker;
use strict;
sub new { bless {}, shift } # By default, do nothing.
sub new { bless {}, shift } # By default, do nothing.
-sub do_it {
- my ($self, $r) = @_;
- my $template = Template->new({ INCLUDE_PATH => [ $self->paths($r) ]});
- my $output;
- if ($template->process($r->template, { $self->args($r) }, \$output)) {
- $r->{output} = $output;
- return 1;
- } else {
- $r->{error} = $template->error;
- }
-
-}
-
sub process {
my ($self, $r) = @_;
sub process {
my ($self, $r) = @_;
- $self->template($r) || return $self->error($r);
+ my $status = $self->template($r);
+ return $self->error($r) if $status != OK;
$r->{content_type} ||= "text/html";
$r->{content_type} ||= "text/html";
$r->{content_type} = "text/plain";
$r->{output} = $r->{error};
$r->send_output;
$r->{content_type} = "text/plain";
$r->{output} = $r->{error};
$r->send_output;
}
sub template { die shift()." didn't define a decent template method!" }
}
sub template { die shift()." didn't define a decent template method!" }
package Maypole::View::Mason;
use base 'Maypole::View::Base';
use HTML::Mason;
package Maypole::View::Mason;
use base 'Maypole::View::Base';
use HTML::Mason;
sub template {
my ($self, $r) = @_;
sub template {
my ($self, $r) = @_;
);
$mason->exec($r->template, $self->vars($r))
$r->{output} = $output;
);
$mason->exec($r->template, $self->vars($r))
$r->{output} = $output;
package Maypole::View::TT;
use base 'Maypole::View::Base';
package Maypole::View::TT;
use base 'Maypole::View::Base';
use Template;
sub template {
use Template;
sub template {
my $output;
if ($template->process($r->template, { $self->vars($r) }, \$output)) {
$r->{output} = $output;
my $output;
if ($template->process($r->template, { $self->vars($r) }, \$output)) {
$r->{output} = $output;
} else {
$r->{error} = $template->error;
} else {
$r->{error} = $template->error;