Search code examples
javascriptjsonmustache

mustache js : is it possible to have mustache render html that is within the json object being passed in?


Is it possible to have mustache render html that is within the json object being passed in? Here is an example :

json object

{
    message : "Hello World! <em>How are you?</em>"
}

template

<p>{{message}}</p>

current output

Hello World! <em>How are you?</em>

desired output

Hello World! How are you?


Solution

  • The default behavior is to escape all variables in Mustache. But you can do unescaped HTML like this {{{ message }}}.

    See http://mustache.github.io/mustache.5.html