Zim::Template.3pm

Langue: en

Version: 2009-03-16 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Zim::Template - Simple templating module

SYNOPSIS

         my $data = {
                 version => '1.0',
                 links => [qw/a b c/],
                 body => \&page_to_html,
         };
         my $t = Zim::Template->new('./template.html');
         $templ->process($data => './page.html');
 
 

DESCRIPTION

Simple templating module. Template syntax is as follows:
         [% var %]
         [% hash.key %]
         [% strftime("%c", var) %]
         [% IF var %] .. [$ END %]
         [% IF var %] .. [% ELSE %] ... [$ END %]
         [% FOREACH name = var %] ... [% name %] ... [% END %]
 
 

The template is tokenized and kept in memory. Thus this module is most efficient when you want to dump many pages with one template.

IO

This module supports various IO methods for both in- and output. IO arguments can be any of the following: a file name, a File object, an IO object or file handle or a scalar reference.

DATA

The DATA hash used contains the variables and data structures used to fill in template fields. Any code references in the data structure are used to autoload data and will be called only once.

METHODS

"new(IO, NAME, LINE)"
Constructor. Reads and parses a template from IO. NAME and LINE are optional and are used for error reporting.
"process(\%DATA => IO)"
Wraps "set_data()" and "output()" in one call.
"set_data(\%DATA)"
Set the data hash.
"output(IO)"
Combine the template with the data and write to IO.

AUTHOR

Jaap Karssenberg (Pardus) <pardus@cpan.org>

Copyright (c) 2006 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO