Remove empty lines from output

Managed by | Updated .

Background

Blanks lines can cause problems when generating output in structured formats such as CSV. Freemarker includes a compress directive that is designed to strip out blank lines making it easier to create a template that outputs in these formats.

Compress directive

The <#compress> tag can be used to remove blank lines from output. This allows for an easy-to-read template that doesn't print superfluous white space. This is particularly important if you are generating a Funnelback configuration file with your Freemarker template.

Wrap <#compress> tags around any sections of the template where you want blank lines removed in the output.

If you want all line breaks removed between the tags and the wrapped content put onto a single line then use  <@compress single_line=true>

Further reading

Freemarker documentation: Compress directive Freemarker documentation: White space handing - using the compress directive

Was this artcle helpful?

Tags
Type: Keywords:
Features:
XML
Frontend > Modern UI Frontend > Freemarker

Comments