use File::Spec;
use UNIVERSAL::moniker;
use strict;
+use Maypole::Constants;
sub new { bless {}, shift } # By default, do nothing.
%args;
}
-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) = @_;
- $self->template($r) || return $self->error($r);
+ my $status = $self->template($r);
+ return $self->error($r) if $status != OK;
$r->{content_type} ||= "text/html";
- return 200;
+ return OK;
}
sub error {
$r->{content_type} = "text/plain";
$r->{output} = $r->{error};
$r->send_output;
+ return ERROR;
}
sub template { die shift()." didn't define a decent template method!" }
package Maypole::View::Mason;
use base 'Maypole::View::Base';
use HTML::Mason;
+use Maypole::Constants;
sub template {
my ($self, $r) = @_;
);
$mason->exec($r->template, $self->vars($r))
$r->{output} = $output;
- return 1;
+ return OK;
}
1;
package Maypole::View::TT;
use base 'Maypole::View::Base';
+use Maypole::Constants;
use Template;
sub template {
my $output;
if ($template->process($r->template, { $self->vars($r) }, \$output)) {
$r->{output} = $output;
- return 1;
+ return OK;
} else {
$r->{error} = $template->error;
- return 0;
+ return ERROR;
}
}