]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Apache/MVC/View/TT.pm
Now it really is producing pages.
[maypole.git] / lib / Apache / MVC / View / TT.pm
index 9cdc0dfef450b147b4fadaa276e76379ff880230..f1b005e8108ac5a37260cdf2a77874b4bd235b08 100644 (file)
@@ -3,6 +3,7 @@ use Lingua::EN::Inflect;
 use Template;
 use File::Spec;
 use UNIVERSAL::moniker;
+use strict;
 
 
 sub new { bless {}, shift } # Not worth having
@@ -20,12 +21,22 @@ sub _tt {
 
 sub _args {
     my ($self, $r) = @_;
+    my $class = $r->model_class;
     my %args = (
         request => $r,
-        class   => $r->model_class,
+        class   => $class,
         objects => $r->objects,
         # ...
     );
+    $args{classmetadata} = {
+        name => $class,
+        columns => [ $class->columns ],
+        colnames => { $class->column_names },
+        moniker => $class->moniker,
+        plural  => $class->plural_moniker,
+        cgi => { $class->to_cgi },
+        description => $class->description
+    };
 
     # User-friendliness facility for custom template writers.
     if (@{$r->objects} > 1){
@@ -44,16 +55,14 @@ sub process {
     || $self->error($r, $template->error);
     $r->{ar}->content_type("text/html");
     $r->{ar}->headers_out->set("Content-Length" => length $output);
-    $r->send_http_header;
-    $r->print($output);
+    $r->{ar}->send_http_header;
+    $r->{ar}->print($output);
     return 200;
 }
 
 sub error {
     my ($self, $r, $error) = @_;
-    $r->{ar}->content_type("text/plain");
-    $r->send_http_header;
-    $r->print($error);
-    return 500;
+    $r->{ar}->send_http_header("text/plain");
+    $r->{ar}->print($error);
     exit;
 }