Will
Will

Reputation: 925

Ignoring all line feeds in a FreeMarker template

I'm trying out FreeMarker, not for a web application but to generate text within a desktop application. I'd like to get the text without any linefeeds, however it always appends a linefeed. For example, this would produce "blah blah\n"

<#if docType=1>
blah blah
<#if docType=2>
more blah
<#/if>

Any ideas? Bunching it all into one line works, but is horrible. Thanks.

Upvotes: 0

Views: 4071

Answers (3)

jaktrip
jaktrip

Reputation: 31

<@compress single_line=true>...</@compress>

...this will output everything in between the compress tag as one line.

Upvotes: 1

Greg Case
Greg Case

Reputation: 3240

I would also take a look at t,lt, and rt directives.

Using your example,

<#if docType=1>
blah blah <#t>
<#if docType=2>
more blah<#t> 
<#/if>

Should produce blah blah more blah on a single line

Upvotes: 2

Istao
Istao

Reputation: 7585

See perhaps White-space handling, ftl and compress directives. But you can't suppress all linefeeds.

Another solution : filter the output, and replace \n by " ".

Upvotes: 3

Related Questions