Search code examples
perltemplate-toolkit

What is the difference between [% %] and [%- -%] in Template Toolkit?


What is the difference between [% %] and [%- -%] in Template Toolkit?


Solution

  • 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 the PRE_CHOMP and POST_CHOMP options for further details.

    See Template::Manual::Config for good examples of the effects with and without pre and post chomping.