handlebars.java icon indicating copy to clipboard operation
handlebars.java copied to clipboard

Replace helper is unable to replace newlines

Open jtreanor opened this issue 5 years ago • 1 comments

I encountered this issue while using Handlebars.java with WireMock but have also reproduced it using the Handlebars.java server. Below is the example to reproduce this.

newlines.hbs:

{{replace (content) '\n' ' '}}

newlines.json:

{
    "content": "A\nB\nC"
}

curl -s http://localhost:6780/newlines.hbs gives the following response:

A
B
C

As you can see, the newlines have not been replaced. The replace helper works correctly for any other string (e.g. replace (content) 'A' 'B').

Am I doing something wrong here? If you can point me in the right direction, I would be happy to tackle a fix for this.

Tested with Handlebars.java 4.1.2

jtreanor avatar May 27 '19 13:05 jtreanor

Having this problem too, also while using Handlebars with Wiremock.

pezholio avatar Oct 03 '22 12:10 pezholio