Alex Rivera | Logout

Velocity Templates - New Line

Asked 2010-12-28T20:52:27.453
18

I've been working with Apache's Velocity engine and a custom template.
The thing is, that I haven't been able to generate a String with the corresponding line breaks. I tried almost everything that I found, such as using $esc.n and $esc.newline (I'm already using escape tools on my project) but it seems that the version I'm currently using doesn't support it (1.4), checked if putting '\n', '\\n' and even '\\\n' would work, but same thing.

Does anyone have any solution to this?

Edit
Report

1 Answer

5

Are you using Velocity to generate HTML content? In that case remember that you need to use <br> not a newline.

If you actually want a new line character you just put the actual new line character, i.e. press enter. There is no escape sequences like \n in Velocity.

answered 2010-12-28T21:09:04.327

Your Answer