NAME
Template - Templates processing module
VERSION
Version 1.21 16.05.2006
SYNOPSIS
print "Content-type: text/html\n\n"; unshift(@INC,module_directory_absolute_path); require Template;
or
use lib module_directory_absolute_path; use Template;
Object $template creation
$template = new Template(template_file,username,user_password, cache_files_absolute_path, timeout);
Update object $template
$template->update(template_file,username,user_password, cache_files_absolute_path, timeout);
- template_file
-
template filename. The template file have to be located in CGI-script directory or one level up directory.
If the module can't able to obtain access to the file, the error message will be evoked.
- username
-
username of virtual client. The username have to be present in .htaccess file (or in other Apache's configuration file like .htaccess).
Set username blank then you don't use HTTP-authorization via Apache.
- user_password
-
User password of virtual client. See username
- cache_files_absolute_path
-
Absolute path to the cache directory. Cache will not be used when this parameter is not presented.
- timeout
-
Timeout is the period (in seconds) of template's updating delay. Default value is 1200 seconds
Modification of labels (cgi labels)
$template->cast({label=>value, label=>value, ...=>...});
- label
-
Label - name will be replaced with appropriate value in tag <!-- cgi: label -->
- value
-
Value - Value, which CGI-script sets. Member of label
Block labels modification (val labels)
$template->cast_loop ("block_name", [{label=>value, label=>value, ...=>...}]);
- block_name
-
Block_name - Block identification name. The name will be inserted in tags <!-- do: block_name --> and <!-- loop: block_name --> - all content between this tags processes like labels, but the tag will be formed as <!-- val: label -->
Block finalizing
$template->finalize(block_name);
Block finalizing uses for not-processed blocks deleting. You need use finalizing every time you use blockes.
Template finalizing
print $template->html || 'Inner error!';
The procedure will return formed document after template processing.
DESCRIPTION
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>
ENVIRONMENT
No environment variables are used.
SEE ALSO
perl
DIAGNOSTICS
The usual warnings if it cannot read or write the files involved.
HISTORY
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.
THANKS
Thanks to Andrew Syrba for useful and valuable information
AUTHOR
Lepenkov Sergey (Serz Minus), minus@mail333.com
COPYRIGHTS
Copyright (C) 1998-2006 D&D Corporation. All Rights Reserved