handlebars.java
handlebars.java copied to clipboard
Replace helper is unable to replace newlines
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
Having this problem too, also while using Handlebars with Wiremock.