1 package Apache::MVC::View::TT;
2 use Lingua::EN::Inflect;
5 use UNIVERSAL::moniker;
9 sub new { bless {}, shift } # Not worth having
13 my $root = $r->config->{template_root};
14 Template->new({ INCLUDE_PATH => [
16 File::Spec->catdir($root, $r->model_class->moniker),
17 File::Spec->catdir($root, "custom"),
18 File::Spec->catdir($root, "factory")
24 my $class = $r->model_class;
28 objects => $r->objects,
31 $args{classmetadata} = {
33 columns => [ $class->columns ],
34 colnames => { $class->column_names },
35 moniker => $class->moniker,
36 plural => $class->plural_moniker,
37 cgi => { $class->to_cgi },
38 description => $class->description
41 # User-friendliness facility for custom template writers.
42 if (@{$r->objects} > 1){
43 $args{$r->model_class->plural_moniker} = $r->objects;
45 ($args{$r->model_class->moniker}) = @{$r->objects};
52 my $template = $self->_tt($r);
54 $template->process($r->template, { $self->_args($r) }, \$output)
55 || $self->error($r, $template->error);
56 $r->{ar}->content_type("text/html");
57 $r->{ar}->headers_out->set("Content-Length" => length $output);
58 $r->{ar}->send_http_header;
59 $r->{ar}->print($output);
64 my ($self, $r, $error) = @_;
65 $r->{ar}->send_http_header("text/plain");
66 $r->{ar}->print($error);