NAME

OpenFrame::WebApp::Template - abstract class for template processing wrappers

SYNOPSIS

# 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;
}

DESCRIPTION

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.

METHODS

types

set/get the hash of $template_types => $class_names known to this class.

processor()

set/get the template processor (ie: tt2 instance).

file()

set/get local path to template file.

template_vars()

set/get hash of template processing variables.

process()

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.

SUB-CLASSING

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.

AUTHOR

Steve Purkis <spurkis@epn.nu>

Inspired by OpenFrame::AppKit::Segment::TT2 by James A. Duncan.

COPYRIGHT

Copyright (c) 2003 Steve Purkis. All rights reserved. Released under the same license as Perl itself.

SEE ALSO

OpenFrame::WebApp::Template::Factory, OpenFrame::WebApp::Template::Error, OpenFrame::WebApp::Template::TT2, OpenFrame::WebApp::Template::Petal,