Mango::Catalyst::View::Template - View class for template based output
Mango::Catalyst::View::Template renders content using one of the following supported Catalyst views:
and serves it with the
Creates a new view for use in Catalyst.
The following method attribute are available:
Sets the template to be used for the current action.
Gets/sets the value of the Content-Type header to get sent with the rendered output.
Renders content using the specified
view_class and sets the
Gets/sets the list of paths in the share containing templates for the current view.
$self->share_paths([ '/share/templates', '/share/other/templates' ]);
Gets/sets the list of paths in the application root containing templates for the current view.
$self->root_paths([ 'templates', 'other/templates' ]);
Gets/sets the aggregate list of paths in containing templates for the current view. By default, this will be (@root_paths, @share_paths).
$self->template_paths([ 'templates', 'other/templates' '/share/templates', '/share/other/templates' ]);
process is called, the paths in
template_paths will be send to the underlying view instance template search path.
Gets/sets the name of the view class to be used to render content. The default view class is Catalyst::View::TT.
An exception is thrown if the view class can not be loaded.
Gets/sets the instance of the view class to be used to render content.
Gets/sets the name of the template wrapper to be used around rendered content.
Mango::Catalyst::View::Template is the base class for the Text/HTML/XHTML views in Mango. This view is not really meant to be used directly. In most cases, you can simply alter functionality by setting properties of your app specific view subclasses:
MyApp::View::Text; use strict; use warnings; use base qw/Mango::Catalyst::Text/; __PACKAGE__->share('/alternate/share/path); __PACKAGE__->view_class('Catalyst::View::MicroMason'); __PACKAGE__->template_paths([ '/path/to/root/tempates/mason/components/text' ]); 1;
Of course, you can always just roll your own view and use Catalyst::View::TT and the like directly.
When a new instance of the
view_class is created, it is given the list of template paths in
template_paths in which to search for template files.
If <template_paths> is not already defined, the following directories are added in the following order:
If the paths have '%view' in them, that will be replace with the short name of the specified
$self->view_class('Catalyst::View::TT'); 'templates/%view/text' becomes 'templates/tt/text' $self->view_class('Catalyst::View::Mason'); 'templates/%view/text' becomes 'templates/mason/text' $self->view_class('Catalyst::View::HTML::Template'); 'templates/%view/text' becomes 'templates/html-template/text'
Christopher H. Laco CPAN ID: CLACO email@example.com http://today.icantfocus.com/blog/