5

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

ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
Gaurav Rathi
  • 93
  • 10

1 Answers1

10

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.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
ysth
  • 96,171
  • 6
  • 121
  • 214
  • And although it is not remotely related to chomping, I like to use [%- -%] because it aligns very nicely with 4-space tab expansion :-) – RET Mar 24 '15 at 06:33