Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Velocity new line

 
Konstantin Chikarev
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all! I didn't find how to set new line in velocity variable. Construction like #set ($test = "line1\n line2") doesn't do that.

Thanks
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done lots with Velocity, but surprisingly never had to do this.

Have you tried doubling the backslash?
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

are you possibly using Velocity templates for HTML pages? Then of course a newline in the source code wouldn't be the same as a newline in your HTML page (<br> . That's just a thought because I personally have no experience with Velocity...

Marco
 
Konstantin Chikarev
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't use velocity for HTML.
I've tried It renders as . renders as
I am constructing template from peaces and than giving it to velocity. May be that's the cause.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic