GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEXT::TMPL (3)

.ds Aq ’

NAME

Text::Tmpl - Templating system perl library

CONTENTS

SYNOPSIS

<B>use Text::Tmpl;B>

$context = <B>new Text::TmplB>;

$return = $context-><B>set_delimitersB>($opentag,
$closetag);

$return = $context-><B>register_simpleB>($name,
$coderef);

$return = $context-><B>register_pairB>($isnamed,
$open_name, $close_name, $coderef);

$return = $context-><B>alias_simpleB>($old_name,
$new_name);

$return = $context-><B>alias_pairB>($old_open_name,
$old_close_name, $new_open_name,
$new_close_name);

$context-><B>remove_simpleB>($name);

$context-><B>remove_pairB>($open_name);

$context-><B>set_debugB>($to_debug_or_not_to_debug);

$context-><B>set_stripB>($to_strip_or_not_to_strip);

$return = $context-><B>set_dirB>($directory);

$return = $context-><B>set_valueB>($name, $value);

$return = $context-><B>set_valuesB>($hashref);

$subcontext = $context-><B>loop_iterationB>($loop_name);

$subcontext = $context-><B>fetch_loop_iterationB>($loop_name,
$iteration_number);

$output = $context-><B>parse_fileB>($template_filename);

$output = $context-><B>parse_stringB>($template);

$errno = Text::Tmpl::<B>errnoB>();

$errstr = Text::Tmpl::<B>strerrorB>();

DESCRIPTION

    Design goals

simplicity, reusability, speed, complete separation of logic from formatting.

    Feature set

variables, loops, conditionals, extensibility of tags, includes, arbitrary delimiters.

    Usage

For starters, make sure you ’use Text::Tmpl’.

Each function is described below:
<B>newB> This function initializes the library. It allocates and returns the global context structure, and also configures all of the default tag behavior.
<B>set_delimitersB> This function lets you change the delimiters marking the beginning and end of a tag (by default, these are <!--# and -->), for the specified context.
<B>set_valueB> This function stores the name=value pair in the current context.
<B>set_valuesB> This function dumps the name=value pairs from a hash reference into the current context.
<B>set_debugB> This function turns debugging output on or off. Note that debugging output hasn’t been written yet - this is just a placeholder.
<B>set_stripB> This function enables or disables the newline stripping feature. If enabled, the parser removes a single newline (if present) from after any tag.
<B>set_dirB> This function sets the directory where templates will be sought, both by parse_file and by the include tag. Search order is always current directory then this searched directory.

This directory must contain all the necessary punctuation so that appending a filename to it produces a valid path (On unix systems, you have to include the trailing slash on the directory name).

<B>loop_iterationB> This function adds an iteration to the loop named loop_name, and returns a unique context for that loop iteration.
<B>fetch_loop_iterationB> This function retrieves and returns the context for $iteration_number from the loop named $loop_name.
<B>parse_fileB> This function opens $template_filename, and parses the contents of that file as a template, returning the output.
<B>parse_stringB> This function parses template directly, in the same way that Text::Tmpl::parse_file does.
<B>register_simpleB> This function registers a new simple tag named $name, which when encountered will cause the parser to call $coderef. See template_extend(1) for the gory details.
<B>register_pairB> This function registers a new tag pair $open_name/$close_name, which when encountered will cause the parser to call $coderef. See template_extend for the gory details.
<B>alias_simpleB> This function copies the definition of a simple tag, previously registered as $old_name, to also be called by $new_name.
<B>alias_pairB> This function copies the definition of a tag pair, previously registered as $old_open_name/$old_close_name, to also be called by $new_open_name/$new_close_name.
<B>remove_simpleB> This function removes the simple tag $name.
<B>remove_pairB> This function removes the tag pair whose open tag is $open_name.
<B>errnoB> This function returns the error number of the last error - see the RETURN VALUES section below.
<B>strerrorB> This function returns a string describing the last error - see the RETURN VALUES section below.

RETURN VALUES

All of the above functions which return numeric values will return 0 if they fail, or 1 otherwise. The ones which return contexts will return undef if they fail, or a valid pointer otherwise.

A function which fails will also set a global error number, which you can read using the errno() or strerror() package functions.

BUGS

Hopefully none.

AUTHOR

J. David Lowe, dlowe@saturn5.com

SEE ALSO

libtmpl(1), template_syntax(1), template_extend(1)
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TMPL (3) 2008-10-28

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.