package TemplateM; require 5.005; use strict; # # TemplateM - Templates processing module # # Version: 2.20 # Date : 14.04.2008 # =head1 NAME TemplateM - *ML templates processing module =head1 VERSION Version 2.20 14 April 2008 =head1 SYNOPSIS use TemplateM; use TemplateM 2.20; use TemplateM 'galore'; use TemplateM 2.20 'galore'; $template = new TemplateM( -file => 'template_file', -login => 'user_login', -password => 'user_password', -cache => 'cache_files_absolute_path', -timeout => 'timeout', -header => 'HTTP_header', -template => 'HTTP_content' ); my %htm = ( ... ); $template = new TemplateM(\%htm); # DEFAULT: $template->cast({label1=>value1, label2=>value2, ... }); my %h = ( ... ); $template->cast(\%h); $template->cast_loop ("block_label", {label1=>value1, label2=>value2, ... }); $template->finalize ("block_label); $template->cast_if('block_label', predicate); # GALORE: my $block = $template->start('block_label'); $block->loop(label1 => 'A', label2 => 'B', ... ); $template->stash(label1 => 'value1', label2 => 'value2', ...); $block->stash(label1 => 'value1', ... ); $template->ifelse("ifblock_label", $predicate) $block->ifelse("ifblock_label", $predicate) $block->output; $block->finish; $template->output; $template->html("Content-type: text/html\n\n"); =head1 ABSTRACT The TemplateM module means for text templates processing in XML, HTML, TEXT and so on formats. TemplateM is the alternative to most of standard modules, and it can accomplish remote access to template files, has simple syntax, small size and flexibility. Then you use TemplateM, functionality and data are completely separated, this is quality of up-to-date web-projects. =head1 TERMS =head2 Scheme Set of methods prodiving process template's structures. =head2 Template File or array of data which represents the set of instructions, directives and tags of markup languages and statistics. =head2 Directive Name of structure in a template for substitution. There are a number of directives: cgi, val, do, loop, if, else =head2 Structure Structure is the tag or the group of tags in a template which defining a scope of substitution. The structure consist of tag and formatted content: DIRECTIVE: LABEL The structure can be simple or complex. Simple one is like this: or Complex structure is the group of simple structures which constitutive a "section" ... even so: ... ... =head2 Label This is identifier of structure. E.g. foo, bar, baz =head1 DESCRIPTION =head2 SCHEMES While defining use it can specify 2 accessible schemes - galore or default. It is not obligatory to point at default scheme. Default scheme is basic and defines using of basic methods: C Default scheme methods is expedient for small-datasize projects. Galore scheme is the alternative for base scheme and it defines own set of methods: C In order to get knowing which of schemes is activated you need to invoke methods either module() or scheme() my $module = $template->module; my $module = $template->scheme; =head2 CONSTRUCTOR Constructor new() is the principal method independent of selected scheme. Almost simple way to use the constructor is: my $template = new TemplateM( -cache => "." ); This invoking takes directive to use template file named index.shtml in current directory and uses the current directory for cache files storage. Below is the attribute list of constructor: =over 8 =item file B