NAME

OpenInteract::Template::Process - Process OpenInteract templates

SYNOPSIS

# Specify an object by name and package

my $html = $R->template->handler( {}, { key => 'value' },
                                  { db      => 'this_template',
                                    package => 'my_pkg' } );

# Specify an object by fully-qualified name

my $html = $R->template->handler( {}, { key => 'value' },
                                  { name => 'my_pkg::this_template' } );

# Directly pass text to be parsed

my $little_template = 'Text to replace -- here is my login name: ' .
                      '[% login.login_name %]';
my $html = $R->template->handler( {}, { key => 'value' },
                                  { text => $little_template } );

# Pass the already-created object for parsing (rare)

my $site_template_obj = $R->site_template->fetch( 51 );
my $html = $R->template->handler( {}, { key => 'value' },
                                  { object => $site_template_obj } );

# Specify a file (rare)

my $html = $R->template->handler( {}, { key => 'value' },
                                  { file => 'filename.tmpl' } );

my $template_results = $R->template->handler( {}, { foo => 'bar' },
                                              { name => 'mypackage::mytemplate' });

DESCRIPTION

This class processes templates within OpenInteract. The main method is handler() -- just feed it a template name and a whole bunch of keys and it will take care of finding the template (from a database, filesystem, or wherever) and generating the finished content for you.

METHODS

handler( \%tmpl_params, \%tmpl_variables, \%tmpl_source )

Generate template content, given keys in \%tmpl_variables and a template identifier in \%tmpl_source.

Parameters:

  • tmpl_params (\%)

    Configuration options for the template. Note that you can set defaults for these at configuration time as well.

  • tmpl_variables (\%)

    The key/value pairs that will get plugged into the template. These can be arbitrarily complex, since the Template Toolkit can do anything :-)

  • tmpl_source

    Tell the method how to find the source for the template you want to process. There are a number of ways to do this:

    Method 1: Name and package (separately)

    db      => 'template_name',
    package => 'package_name'

    Note that both the template name and package are required. This is a change from older versions when the template package was optional.

    Method 2: Use a combined name

    name    => 'template_name::package_name'

    Method 3: Specify the text yourself

    text    => $scalar_with_text
    or
    text    => \$scalar_ref_with_text

    Method 4: Specify an object of type OpenInteract::SiteTemplate

    object => $site_template_obj

initialize( \%config )

Creates a TT processing object with our necessary parameters and returns it.

BUGS

None known.

TO DO

Nothing known.

SEE ALSO

Template

OpenInteract::Template::Context

OpenInteract::Template::Plugin

OpenInteract::Template::Provider

COPYRIGHT

Copyright (c) 2001 intes.net, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>