Handlebars Escape String

ember.js, handlebars.js, javascript

Solution

I know the question is from 2014, Handlebars documentation now proposes this simple solution:

use "triple-stash" like this `{{{expression}}}` if you don't want to escape a value.

If you want more control register an helper like explained in the example given from the same documentation.

Problem

Currently, I'm running into a problem with the triple-stash helper in handlebars. I have a string coming from a service which I do not have control of and it is returning escaped html which has already escaped html inside of it. To clarify below is an example: ``` &lt;p&gt;&amp;lt;span class=\"font-bold\"&amp;gt;content content Support&amp;lt;/span&amp;gt;, content content &amp;nbsp; content content content.&lt;/p&gt; ``` Obvisouly, when using the triple-stash, I would get ``` <p>&lt;span class=\"font-bold\"&gt;content content Support&lt;/span&gt;, content content &nbsp; content content content.</p> ``` Since it is nested, the span inside isn't unescaped (if that makes sense). I was wondering if I could overload a method or something to help me recursively unescape. Or is there a better solution out there?

Original source