[Solved] <br/> tag doesn't force a newline when using handlebars in the template

This question seems to be similar to [Solved] Handlebar snippets rendered as text instead of html and [SOLVED] Handlebar not executed for dynamically loaded HTML but they both use custom handlebars and externally loaded files or programmatic modifications through scripts.

My issue today is slightly different, and I didn’t manage to adapt any of the solutions in those threads to the issue at hand.


What character can be placed inside a XML string node so that it gets correctly rendered as a newline in the template?


The Datamapper extracts a XML field, let’s call it “Corpus” and place it inside the datamapper field “Corpus” without any manipulation. The data is correct from the source.

Corpus = "a <br/> b <br/> c"

Later in the Template I place down the field content as

<p>
  {{ Corpus }}
</p>

And the rendered output is without the new line.

image


If in the source I enter &lt; br/ &gt; the rendered text literally shows the <br/> string

image

I am fiddling with other characters with no success.

Hi @Maxiride,

HBS expression results are HTML-escaped by default. If a field contains HTML tags you can prevent HTML-escaping with a triple-stache: {{{ Corpus }}}. For more information about triple-staches see DevDocs. (I now notice that they use the spelling “triple-stash”, which makes no sense to me since the term is derived from “moustache”.)

Normally a triple-stache is applied automatically after dragging a field to the editor, but only if you assign the type “HTML String” rather than “String” in the DM step properties. The designer needs to know that the field value contains HTML.

See also the note on this page about “HTML String”.

As a side note, the trailing slash is not needed, <br> looks cleaner.

Thank you very much Sander for the thorough answer, much appreciated.