문제

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.

도움이 되었습니까?

해결책

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}}}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top