Template-Toolkit
view release on metacpan or search on metacpan
lib/Template/FAQ.pod view on Meta::CPAN
+ config/macros
+ "config/style/$style"
+ "config/section/$section"
+ ...
%]
This allows me to set a single 'style' variable to control which config
file gets pre-processed to set my various style options (colours, img paths,
etc). For example:
config/style/basic:
[% style = {
name = style # save existing 'style' var as 'style.name'
# define various other style variables....
col = {
back => '#ffffff'
text => '#000000'
# ...etc...
}
logo = {
# ...etc...
}
# ...etc...
}
%]
Each source template can declare which section it's in via a META
directive:
[% META
title = 'General Information'
section = 'info'
%]
...
This controls which section configuration file gets loaded to set various
other variables for defining the section title, menu, etc.
config/section/info:
[% section = {
name = section # save 'section' var as 'section.name'
title = 'Information'
menu = [ ... ]
# ...etc...
}
%]
This illustrates the basic principal but you can extend it to perform
pretty much any kind of per-document initialisation that you require.
=head2 Why do I get rubbish for my utf-8 templates?
First of all, make sure that your template files define a Byte Order
Mark L<http://en.wikipedia.org/wiki/Byte_Order_Mark>
If you for some reason don't want to add BOM to your templates, you can
force Template to use a particular encoding (e.g. C<utf8>) for your
templates with the C<ENCODING> option.
my $template = Template->new({
ENCODING => 'utf8'
});
=head1 Questions About This FAQ
=head2 Why is this FAQ so short?
Because we don't have anyone maintaining it.
=head2 Can I help?
Yes please :-)
=cut
# Local Variables:
# mode: perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4:
( run in 0.624 second using v1.01-cache-2.11-cpan-5a3173703d6 )