Derek Gathright![]()
Mustache is a cross-language template library the simplifies the process of creating strings with dynamic values.
Update: As of YUI 3.5.0, Handlebars is a core module available within YUI. Unless there is a specific reason you'd like to use Mustache, it is recommended you use Handlebars instead.
Note: Mustache's performance is slightly slower than Y.substitute. So, if you are in an environment where performance matters and you don't specifically need Mustache, consider using Y.substitute. See perf test @ http://jsperf.com/yui-mustache-vs-y-substitute
More info
http://mustache.github.com/
https://github.com/janl/mustache.js
<script src="//yui.yahooapis.com/3.3.0/build/yui/yui.js"></script>
<script>
YUI({
modules: {
'gallery-mustache': {
fullpath: 'https://github.com/derek/yui3-gallery/raw/master/build/gallery-mustache/gallery-mustache.js'
}
}
}).use('gallery-mustache', function(Y) {
var template = "{{title}} spends {{calc}}";
var view = {
title: "Joe",
calc: function() {
return 2 + 4;
}
}
var output = Y.mustache(template, view);
console.log(output);
});
</script>| Subject | Author | Date |
|---|---|---|
| jsfiddle example: | Andrew Wooldridge | 05/25/11 |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info