CGI::Application::Plugin::View::HTML::Template - Automatically render HTML::Templates in CGI::Application
use base CGI::Application; use CGI::Application::Plugin::View::HTML::Template; use CGI::Application::Plugin::Stash; # Recommended sub setup { my $self = shift; $self->start_mode('mode1'); $self->mode_param('rm'); $self->run_modes( 'mode1' => 'do_stuff', ... ); } sub do_stuff { $self->stash->{foo} = 'bar'; $self->stash->{template} = $self->load_tmpl('some.tmpl'); return; }
CGI::Application::Plugin::View adds Catalyst-like view processing to CGI::Application. This module automatically renders templates without setting template params or calling the template output method.
This module has no methods. Simply store your template and var(s) (CGI::Application::Plugin::Stash is recommended), and return from your runmode without returning template output. This module will automatically populate variables found in your template, and output it.
This module was inspired by Plugin::Stash. When I read the Catalyst::Manual::Tutorial two things seemed elegant to me: Stash and the way the template is processed automatically when the controller method is left. When I saw Plugin::Stash it caused me to remember the other thing I liked. So, I created this module. It doesn't do much. At a minimum it's a simple example of how to use CGI::Application's "add_callback" to postrun.
CGI::Application
HTML::Template
Catalyst
For additonal Catalyst-like functionality, see:
CGI::Application::Plugin::ActionDispatch
CGI::Application::Plugin::DebugScreen
CGI::Application::Plugin::Forward
CGI::Application::Plugin::Stash
Mark Fuller, mfuller at c p a n /.\ o r g
Copyright (C) 2008 by Mark Fuller
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install CGI::Application::Plugin::View::HTML::Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Application::Plugin::View::HTML::Template
CPAN shell
perl -MCPAN -e shell install CGI::Application::Plugin::View::HTML::Template
For more information on module installation, please visit the detailed CPAN module installation guide.