Mango::Catalyst::View::Template - View class for template based output
$c->view('Template');
Mango::Catalyst::View::Template renders content using one of the following supported Catalyst views:
Catalyst::View::TT
and serves it with the content_type specified.
content_type
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.
$self->content_type('text/html');
Renders content using the specified view_class and sets the content_type.
view_class
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' ]);
When process is called, the paths in template_paths will be send to the underlying view instance template search path.
process
template_paths
Gets/sets the name of the view class to be used to render content. The default view class is Catalyst::View::TT.
$self->view_class('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.
$self->wrapper('wrapper');
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:
$c->path_to('root')/root_paths $c->share/share_paths
If the paths have '%view' in them, that will be replace with the short name of the specified view_class:
$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 claco@chrislaco.com http://today.icantfocus.com/blog/
To install Mango, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mango
CPAN shell
perl -MCPAN -e shell install Mango
For more information on module installation, please visit the detailed CPAN module installation guide.