5

I want to put newlines and whitespaces in my velocity template to make it more readable. But my output must conform to a format that does not accept newlines and whitespaces.

Can velocity be configured to ignore whitespaces?

flybywire
  • 261,858
  • 191
  • 397
  • 503
  • Have a look at http://stackoverflow.com/questions/8594022/how-can-i-trim-whitespace-by-velocity. Seems to be exactly what you are looking for. – Mike de Dood May 22 '13 at 08:27
  • the exact oppostie, @Kamikaze_lux. I want to eliminate all whitespace present in the template itself, while keeping whitespace that comes from function calls and variable interpolation, if any. – flybywire May 22 '13 at 12:11

1 Answers1

1

By default no, but it is possible to do it if you're in control of how the templates are rendered. You can check how XWiki does this: it uses a configurable filter to pre-process the Velocity code to remove white space, and perhaps the indent filter is the one that suits your needs.

Sergiu Dumitriu
  • 11,455
  • 3
  • 39
  • 62