| OpenFrame-WebApp documentation | view source | Contained in the OpenFrame-WebApp distribution. |
OpenFrame::WebApp::Template - abstract class for template processing wrappers
# abstract class - does nothing on its own
use OpenFrame::WebApp::Template::SomeClass;
my $tmpl = new OpenFrame::WebApp::Template::SomeClass()
->file( $local_path )
->template_vars( { some => vars } );
try {
$ofResponse = $tmpl->process;
} catch OpenFrame::WebApp::Template::Error with {
my $e = shift;
print $e->flag, $e->message;
}
The OpenFrame::WebApp::Template class is an abstract wrapper around a
template system like Template::Toolkit, HTML::Template, Petal, etc.
This class was meant to be used with OpenFrame::WebApp::Template::Factory.
set/get the hash of $template_types => $class_names known to this class.
set/get the template processor (ie: tt2 instance).
set/get local path to template file.
set/get hash of template processing variables.
process the template file with the template processing variables, and produce
an OpenFrame::Response with the result. throws an
OpenFrame::WebApp::Template::Error if there was a problem.
Read through the source of this package and the known sub-classes first. The minumum you need to do is this:
use base qw( OpenFrame::WebApp::Template );
OpenFrame::WebApp::Template->types->{my_type} = __PACKAGE__;
sub default_processor {
return new Some::Template::Processor();
}
sub process_template {
...
throw OpenFrame::WebApp::Template::Error( ... ) if ($error);
return $output;
}
You must register your template type if you want to use the Template::Factory.
Steve Purkis <spurkis@epn.nu>
Inspired by OpenFrame::AppKit::Segment::TT2 by James A. Duncan.
Copyright (c) 2003 Steve Purkis. All rights reserved. Released under the same license as Perl itself.
OpenFrame::WebApp::Template::Factory, OpenFrame::WebApp::Template::Error, OpenFrame::WebApp::Template::TT2, OpenFrame::WebApp::Template::Petal,
| OpenFrame-WebApp documentation | view source | Contained in the OpenFrame-WebApp distribution. |