Reputation: 53
In my code I am using "\n" for line breaks.
It was suggested that I need to avoid "\n" because this is different for different OS (UNIX, windows and MAC) and each operating system would interpret this character differently.
Though I am seeing the expected behavior, can anybody suggest, do we have any function for line break in free marker
Upvotes: 4
Views: 22778
Reputation: 5165
use ${'\n'} for inserting new line in specific place of the template
Upvotes: 11
Reputation: 31162
FreeMarker itself doesn't care which line break are you using inside the templates, and it will output exactly the same kind of line breaks that you are using in the templates.
If you need to convert the line breaks in the output, that you should do with the Writer
that you pass to FreeMarker. You could use a java.io.FilterWriter
implementation for that (perhaps there's some out there, but if not, it's no difficult to write your own).
And yes, some applications (like Windows Notepad) doesn't handle foreign line-breaks correctly. It all depends on the application the has to read the file.
Upvotes: 0