Velocity not displaying Line feeds in text field

I have a sys_TextArea field that contains line feeds (allowing paragraphs). I’m trying to display this in a Velocity template with either #field or #displayfield macros, but the sentences are displayed without line feeds.

When this was XSL, I had to call an XSL procedure to deal with this. Is there an equivalent Velocity macro?



I’m not aware of any such method. You would have to write a small Java method that replaced newlines w/ <p> tags.

I found some VTL that may solve your problem. It works on data submitted from a windows machine. Not sure if it will work if the data submitted from a Unix box.

#set($foo = $sys.item.getProperty(‘field’).String)
$foo.replace($rx.codec.decodeFromXml(" "), “<p>”)

If you care about “well formed” XHTML, you might want to consider using <br /> instead of <p>

Great - it works!

Thanks Paul and David - my faith in Velocity has been restored (until tomorrow;))