What is the difference between [% %]
and [%- -%]
in Template Toolkit?
The Template Toolkit is an all-Perl template processing system. Unlike many other Perl templating systems, it is as proficient at producing HTML as it is at producing XML, PDF, or any other output format. It has its own simple templating language, so templates can be written and edited by people who do not know Perl.
With functions, pre-defined modules and libraries to use, anyone can easily use the framework to create a basic web application. The usage depends on your requirements. On the other hand, templates are more like reusable boxes that can be used with less tweak (or no tweak at all).
If you want to add functionality to the Template Toolkit or have found a bug that you can fix, and you want your patch to be accepted by Template Toolkit developers, you should make your changes against the current CVS HEAD.
The first major difference is that ttree works with entire directories of templates rather than with single files. If you’re using the Template Toolkit to build a web site, for example, you can point ttree at a directory of source templates to process them all, saving the generated HTML pages to corresponding files in an output directory.
The -
automatically removes some whitespace from before/after the directive tag.
See Template::Manual::Syntax:
You can add
-
or+
to the immediate start or end of a directive tag to control the whitespace chomping options. See thePRE_CHOMP
andPOST_CHOMP
options for further details.
See Template::Manual::Config for good examples of the effects with and without pre and post chomping.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With