TemplateM - Templates processing module
Version 2.00 13.10.2006
unshift(@INC,module_directory_absolute_path); require TemplateM;
or:
use lib module_directory_absolute_path; # if the module is installed in user's directory use TemplateM;
as list:
$template = new TemplateM(template_file,username,user_password, cache_files_absolute_path, timeout, http_header);
or as implicit hash array (every key of hash array must be forestall the ``-'' sign):
$template = new TemplateM(-file=>'template_file',-user=>'username',-password=>'user_password', -cache=>'cache_files_absolute_path', -timeout=>'timeout', -header=>'HTTP_header');
or as reference to hash array or as hash array:
$template = new TemplateM({file=>'template_file',user=>'username',password=>'user_password', cache=>'cache_files_absolute_path', timeout=>'timeout', header=>'HTTP_header'});
$template->update(template_file, username, user_password, cache_files_absolute_path, timeout, http_header);
Method ``update'' is used like ``new'' method, but ``new'' method is more prefer
If the module can't able to obtain access to the file, the error message will be evoked.
Set username blank then you don't use HTTP-authorization via Apache.
if updating delay parameter is ``-1'' the updating delay will be perpetual
$template->cast({label=>value, label=>value, ...=>...});
or
$template->cast(label=>value, label=>value, ...=>...);
$template->cast_loop (``block_name'', [{label=>value, label=>value, ...=>...}]);
or
$template->cast_loop (``block_name'', {label=>value, label=>value, ...=>...});
or
$template->cast_loop (``block_name'', %hash);
$template->cast_if('block_name', 'condition');
method prints blocks according to the condition.
if condition is true the if-block will be printed:
<!-- if: name --> block content if <!-- end_if: name -->
and else-block not will be printed.
If the condition is false, vice versa, else-block will be printed and if-block will be passed
In all of cases names of this blocks must bethe same!
$template->finalize(block_name);
Block finalizing uses for not-processed blocks deleting. You need use finalizing every time you use blockes.
print $template->html(-header=>'HTTP_header') || 'Inner error!';
or
print $template->html({header=>'HTTP_header'}) || 'Inner error!';
or
print $template->html('HTTP_header')
|| 'Inner error!';
The procedure will return formed document after template processing. if header is present as argument it will be added at the beginning of template's return.
The module can be used with SSI directives together, like in this shtml-sample:
<html> <!--#include virtual="head.htm"--> <body> <center><!-- cgi: head --><center> <!-- do: BLOCK_P --> <p><!-- val: content --></p> <!-- loop: BLOCK_P --> </body> </html>
No environment variables are used.
perl
The usual warnings if it cannot read or write the files involved.
1.00 Initial release
1.10 Working with cache ability is added
1.11 Inner method's interface had structured
1.21 New time managment for templates caching. You can set how long template file will be cached before renew.
2.00 - Simultaneous templates using errors is eliminated. - Alternate interface of using methods is added. - Method of conditional representation of template CAST_IF is added.
Thanks to Andrew Syrba for useful and valuable information. Thanks to Dmitry Klimov for technical translating.
Lepenkov Sergey (Serz Minus), minus@mail333.com
Copyright (C) 1998-2006 D&D Corporation. All Rights Reserved