X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FApache%2FMVC%2FView%2FTT.pm;h=f1b005e8108ac5a37260cdf2a77874b4bd235b08;hb=58398cbb7b75bf3106e8503b81ee782178c248c3;hp=9cdc0dfef450b147b4fadaa276e76379ff880230;hpb=bc6b985ccc8ac4bb7e5afa36dcfb1df9e5e47904;p=maypole.git diff --git a/lib/Apache/MVC/View/TT.pm b/lib/Apache/MVC/View/TT.pm index 9cdc0df..f1b005e 100644 --- a/lib/Apache/MVC/View/TT.pm +++ b/lib/Apache/MVC/View/TT.pm @@ -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; }