Comments (3)
Hi Peter,
Could you provide a complete example which includes your template markup
and the viewData object in order for me to help you with this issue?
Thanks
On 26 Jun 2013 08:35, "PeterSloth" [email protected] wrote:
Hi
I use the code below to render mark-up for my Preview element.
$('#Preview).mustache('my-template', viewData, { method: 'html' });
The viewData contains fields that contain raw text as well as fields which
contain html markup. The problem is that the html markup is not rendered,
so instead of showing for instance Hello World in bold the Preview element
shows Hello World
Is this a bug or am I doing something wrong?Thanks
Peter—
Reply to this email directly or view it on GitHubhttps://github.com//issues/26
.
from jquery-mustache.
Hi John
I tried to include the sample on the web site, but a lot markup was removed which made it unreadable, so I here it is:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="resources/scripts/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="resources/scripts/mustache.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.mustache.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var viewData = { name: '<b>Jonny</b>' };
$.Mustache.add('my-template', '<p>Hi, {{name}}, this is an inline template<p>');
$('#Preview').mustache('my-template', viewData, { method: 'html' });
});
</script>
</head>
<body>
<div id="Preview"></div>
</body>
</html>
from jquery-mustache.
mustache.js automatically HTML-escapes all tags wrapped in {{ }}
's. If you don't want mustache.js to HTML-escaped then you need to use either triple mustaches ({{{name}}}
) or an ampersand in front the variable name {{&name}}
So your code should be changed to read:
$.Mustache.add('my-template', '<p>Hi, {{{name}}}, this is an inline template with HTML Markup<p>');
from jquery-mustache.
Related Issues (20)
- window.Mustache is not set? HOT 4
- addFromDom() only gets templates from the body HOT 3
- addFromDom() doesn't work unless a template name is specified HOT 3
- Options.method ambiguous and dangerous HOT 2
- Allow default `$.fn.mustache` 'method' to be configured.
- $("selector").mustache(template,data) should return jquery function for the new element HOT 1
- option to assign templateData to rendered template instance HOT 1
- Syntax error in the README.md HOT 1
- Load template file once and access templates in it several times HOT 4
- expose 'has' function HOT 4
- Failed to locate Mustache instance, are you sure it has been loaded? HOT 2
- [enhancement] Add missing bower.json.
- Altering mustache.load() to use within .when() HOT 6
- jquery1.9 load problems HOT 1
- jquery-Mustache and requireJS (AMD) HOT 1
- Getting a 404 despite having the right path, why? HOT 3
- unobstrusive function call not working HOT 6
- How to Use Parse?
- Events not fire on templates elements after load - Please put it in the read.me
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-mustache.