Re: Omitting template markup characters

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Monday, April 26, 2010, 6:07:22 PM, Kjeld wrote:

>
> Hi,
>
> I am trying to output a simple text file using Freemarker. I noticed that
> the markup of the template file is copied to the output file: carriage
> returns, linefeeds, indentations, blank spaces, all that are 'outside' the
> markup tags are copied into the output stream as well, next to the text I am
> actually trying to produce. 
>
> Is it possible to configure Freemarker in such a way that all markup
> characters in the template file will be omitted and only the characters that
> are inside the tags are copied to the output file? 
>
> E.g. I want the following template
>
> <#list 1..5 as i>
>         ${'a'}
> </#list>
>
> ...to return: aaaaa instead of 
>      a
>      a
>      a
>      a
>      a
>
> Thanks, 
> Kjeld

Are you using Coniguration.getPlainTextTemplate? Because then that's
the problem. The purpose of that method is exactly to get a template
that just outputs the source file as is. Use getTemplate instead, then
it will work. Admittedly there is a misnomer here, as
getPlainTextTemplate should be called getStaticTextTemplate... Since
FreeMarker doesn't care about MIME types and is not HTML-aware,
getTemplate can be used for everything, and so for text/plain as well.

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.