Ravi Ram
Ravi Ram

Reputation: 24488

Mustachejs render html markup as html

We are converting an old CMS using Mustachejs. The BODY of the content contains some html elements:

<strong>Mickey Mouse</strong> is a funny animal cartoon character created in 1928 by Walt Disney.

We we apply the value to Mustachejs like {{Description}}

The output rendered is

<strong>Mickey Mouse</strong> is a funny animal cartoon character
created in 1928 by Walt Disney.

Mustachejs literally displays the value as it is in the database.

How do we get Mustachejs to render the html markup as html?

Desired Result

Mickey Mouse is a funny animal cartoon character created in 1928 by Walt Disney.

Upvotes: 6

Views: 5646

Answers (1)

Popnoodles
Popnoodles

Reputation: 28409

It's not literally displaying the value as it is in the db, it's encoding it. It's actually outputting

&lt;strong&gt;Mickey Mouse&lt;/strong&gt;

Use {{{three_braces}}} to have Mustache render without html encoding the string. {{{Description}}}

Upvotes: 25

Related Questions