BBC (British Broadcasting Corporation) > Any-Template-1.015 > Any::Template::Backend

Download:
Any-Template-1.015.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 1.008   Source  

NAME ^

Any::Template::Backend - base class for implementing backends for Any::Template

SYNOPSIS ^

        package Any::Template::Backend::MyTemplate;
        
        use MyTemplate;
        use Any::Template::Backend;
        use vars qw(@ISA);
        @ISA = qw(Any::Template::Backend);
        
        sub new {
                ...             
        }

DESCRIPTION ^

This exists purely to be inherited from. It provides some default implementations of sending output to different sinks based on the lowest common denominator of returning data to a string or filehandle. You can override these implementations with more efficient ones where the templating engine provides them natively.

API FOR BACKEND MODULES ^

$o = new Any::Template::Backend::MyBackend(\%options);

You MUST supply a constructor. There is no default contructor to inherit. The constructor will need to marshal the options and create the backend template object from them. Example implementations can be found in backend classes included with the distribution.

$templating_engine = $o->native_object()

Returns the underlying native template object. You SHOULD supply this method. Although accessing the underlying object defeats the point of Any::Template, a valid use is in refactoring code, where dependencies on a particular engine's API can be eradicated in iterations.

$data = $o->preprocess($data)

You CAN supply a method to preprocess the data structure before it's handed off to one of the process methods listed below. Typically you might use this to remove some values from the data structure (e.g. globrefs) that a template backend might not be able to handle. The default implementation returns $data unmodified.

$o->process_to_string($data, $scalar_ref)

You MUST supply this method. Example implementations can be found in backend classes included with the distribution.

$o->process_to_filehandle($data, $fh)

You CAN supply this method. If you don't, output will be collected in a string and sent to the filehandle.

$o->process_to_sub($data, \&code)

You CAN supply this method. If you don't, output will be collected in a string and sent to the sub.

$o->process_to_file($data, $filename)

You CAN supply this method. If you don't, a filehandle will be opened against this file, and process_to_filehandle will be used to populate it.

VERSION ^

$Revision: 1.8 $ on $Date: 2005/05/08 18:25:16 $ by $Author: johna $

AUTHOR ^

John Alden <cpan _at_ bbc _dot_ co _dot_ uk>

COPYRIGHT ^

(c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.

See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt

syntax highlighting: