use Template::Timer;
use MRO::Compat;
-our $VERSION = '0.30';
+our $VERSION = '0.32';
__PACKAGE__->mk_accessors('template');
__PACKAGE__->mk_accessors('include_path');
use base 'Catalyst::View::TT';
- __PACKAGE__->config->{DEBUG} = 'all';
+ __PACKAGE__->config(DEBUG => 'all');
Now you can modify your action handlers in the main application and/or
controllers to forward to your view class. You might choose to do this
$c->forward( $c->view('TT') );
}
+But if you are using the standard auto-generated end action, you don't even need
+to do this!
+
+ # in MyApp::Controller::Root
+ sub end : ActionClass('RenderView') {} # no need to change this line
+
+ # in MyApp.pm
+ __PACKAGE__->config(
+ ...
+ default_view => 'TT',
+ );
+
+This will Just Work. And it has the advantages that:
+
+=over 4
+
+=item *
+
+If you want to use a different view for a given request, just set
+<< $c->stash->{current_view} >>. (See L<Catalyst>'s C<< $c->view >> method
+for details.
+
+=item *
+
+<< $c->res->redirect >> is handled by default. If you just forward to
+C<View::TT> in your C<end> routine, you could break this by sending additional
+content.
+
+=back
+
+See L<Catalyst::Action::RenderView> for more details.
+
=head2 CONFIGURATION
There are a three different ways to configure your view class. The
The constructor for the TT view. Sets up the template provider,
and reads the application config.
-=head2 process
+=head2 process($c)
Renders the template specified in C<< $c->stash->{template} >> or
C<< $c->action >> (the private name of the matched action). Calls L<render> to
perform actual rendering. Output is stored in C<< $c->response->body >>.
+It is possible to forward to the process method of a TT view from inside
+Catalyst like this:
+
+ $c->forward('View::TT');
+
+N.B. This is usually done automatically by L<Catalyst::Action::RenderView>.
+
=head2 render($c, $template, \%args)
Renders the given template and returns output, or a L<Template::Exception>
process, including the name of a template file or a reference to a test string.
See L<Template::process|Template/process> for a full list of supported formats.
-To use the render method outside of your Catalyst app, just pass a undef context.
+To use the render method outside of your Catalyst app, just pass a undef context.
This can be useful for tests, for instance.
+It is possible to forward to the render method of a TT view from inside Catalyst
+to render page fragments like this:
+
+ my $fragment = $c->forward("View::TT", "render", $template_name, $c->stash->{fragment_data});
+
=head2 template_vars
Returns a list of keys/values to be used as the catalyst variables in the