]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/View/TT.pm
Remove dependency on Apache.
[maypole.git] / lib / Maypole / View / TT.pm
index 47999a4692460dc5137c53bbdd8e3d3dd5e223e7..bdcebb2fee120f62e7ac46f31efd5f89847f75d3 100644 (file)
@@ -1,5 +1,4 @@
 package Maypole::View::TT;
-use Apache::Constants;
 use Lingua::EN::Inflect;
 use Template;
 use File::Spec;
@@ -11,7 +10,8 @@ sub new { bless {}, shift } # Not worth having
 
 sub _tt {
     my ($self, $r) = @_;
-    my $root = $r->{ar}->document_root . "/". $r->{ar}->location;
+    # This bit sucks.
+    my $root = $r->{config}{template_root} || $r->get_template_root;
     Template->new({ INCLUDE_PATH => [
         $root,
         ($r->model_class && File::Spec->catdir($root, $r->model_class->moniker)),
@@ -62,19 +62,18 @@ sub process {
     $template->process($r->template, { $self->_args($r) }, \$output)
     || return $self->error($r, $template->error);
 
-    $r->{ar}->content_type("text/html");
-    $r->{ar}->headers_out->set("Content-Length" => length $output);
-    $r->{ar}->send_http_header;
-    $r->{ar}->print($output);
+    $r->{content_type} ||= "text/html";
+    $r->{output} = $output;
     return 200;
 }
 
 sub error {
     my ($self, $r, $error) = @_;
     warn $error;
-    if ($error =~ /not found$/) { return DECLINED }
-    $r->{ar}->send_http_header("text/plain");
-    $r->{ar}->print($error);
+    if ($error =~ /not found$/) { return -1 }
+    $r->{content_type} = "text/plain";
+    $r->{output} = $error;
+    $r->send_output;
     exit;
 }