NAME
dTemplate - A powerful template handling logic with advanced features.
SYNOPSIS
use dTemplate;
$mail_template = define dTemplate "mail_tmpl.txt";# definition
$mail = $mail_template->parse( # The parsing
TO => "foo@bar.com",
SUBJECT => $subject,
BODY =>
sub { $email_type==3 ? $body_for_type_3 : $body_for_others },
SIGNATURE=> $signature_template->parse( KEY => "value" )
);
print "Please send this mail: $mail";
# Advanced feature: Styling
$style={lang =>'hungarian',color=>'white'}; # Style definition
$html_template = choose dTemplate( $style, # Selector definition
'hungarian+white' => define dTemplate("hun_white_template.html"),
'spanish' => define dTemplate("spanish.html"),
'black+hungarian' => define dTemplate("hun_black_template.html"),
'english' => define dTemplate("english_template.html"),
'empty' =>
"<html>This is a simple text $BODY$ is NOT substituted!!!!"</html>",
'' => text dTemplate "<html>$BODY$</html>",
);
$body_template= choose dTemplate( $style, # Selector definition
'hungarian' => define dTemplate("sziasztok_emberek.html"),
'spanish' => define dTemplate("adios_amigos.html"),
'' => define dTemplate("bye_bye.html"),
);
print $html_template->parse(BODY => $body_template->parse());
# will print "sziasztok_emberek.html" in the
#"hun_white_template.html"
%$style=();
print $html_template->parse(BODY => $body_template->parse());
# will print "bye_bye.html" surrounded by "<html>" and "</html>" tags.
%$style=( lang => 'english' );
print $html_template->parse(BODY => $body_template->parse());
# will print the "bye_bye.html" in of the "english_template.html"
DESCRIPTION
This module wants to be the most powerful general purpose templating system. It has a very clear and easy to learn syntax with the styling capabilities.
All you need to use this: put $TEMPLATE_VARIABLE$ into your dTemplates, define them, and parse them. (You can write $ signs as $$).
FEATURES
General purpose templating. It can be used for texts or htmls, xmls, etc.
Straightforward logic. You can do all the templating in a logical order. Your program code will be very clear and easy to understand.
Special formatting of the variables before variable-substitution: printf-style formatting and encoding.
The format of the variable is $Variable_NAME%printf_format*encoding$
- Printf-Style formatting
-
You can use a printf formatting string in the Template variable name after the % sign, e.g: $ZIP_CODE%8s$
- Encoding
-
You can use URI ('u') or HTML ('h') encoding of the data: <HREF="link.cgi?target=$TARGET_URL*u$">
- Using Both
-
If you want to use both printf-style formatting and Encoding, you must use in the order as declared above, e.g: $PERCENT_COMPLETE%07.3f*h$. The reverse order won't work!
Formattable templates
COPYRIGHT
Copyrigh (c) 2000 Szabó, Balázs (dLux)
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
dLux (Szabó, Balázs) <dlux@kapu.hu>
SEE ALSO
perl(1).
3 POD Errors
The following errors were encountered while parsing the POD:
- Around line 91:
=back doesn't take any parameters, but you said =back 4
- Around line 97:
=back doesn't take any parameters, but you said =back 4
- Around line 101:
Non-ASCII character seen before =encoding in 'Szabó,'. Assuming CP1252