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.
Including Mustache templates with partials You can also include a partial within another partial, which lets you make nested includes. Then, when you run the Mustache processor, you pass your partials object as the third argument, like this: html = Mustache. render( template, data, partials );
DESCRIPTION. Mustache can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object. We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags.
The Mustache templates consist of tag names surrounded by { { } } (which resemble mustaches – hence the name) and are backed by a model object containing the data for the template.
Mustache is a web template system with implementations available for ActionScript, C++, Clojure, CoffeeScript, ColdFusion, Common Lisp, Crystal, D, Dart, Delphi, Elixir, Erlang, Fantom, Go, Haskell, Io, Java, JavaScript, Julia, Lua, .
It's not literally displaying the value as it is in the db, it's encoding it. It's actually outputting
<strong>Mickey Mouse</strong>
Use {{{three_braces}}} to have Mustache render without html encoding the string. {{{Description}}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With