Created
July 13, 2010 19:50
-
-
Save phiggins42/474401 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dojo.provide("dojox.mustache._Templated"); | |
dojo.require("dijit._Widget"); | |
dojo.require("dijit._Templated"); | |
// | |
// INSTALL: copy http://github.com/janl/mustache.js to this folder as _base.js | |
// Add dojox.mustache = dojo.hitch(Mustache, "to_html") in _base.js, wrapping | |
// the whole file in a self-executing-anonymous-function. eg: | |
// | |
// dojo.provide("dojox.mustache._base"); | |
// (function(){ | |
// /* contents of Mustache.js */ | |
// // export to Dojo | |
// dojox.mustache = dojo.hitch(Mustache, "to_html"); | |
// })(); | |
// | |
dojo.require("dojox.mustache._base"); | |
dojo.declare("dojox.mustache._Widget", [dijit._Widget, dijit._Templated], { | |
// prevent from reusing DOM nodes as template, we want to redraw | |
_skipNodeCache:true, | |
_stringRepl: function(template){ | |
// override the default/basic ${foo} substitution in _Templated | |
return dojo.trim(dojox.mustache(template, this)); // String | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="../../../dojo/dojo.js"></script> | |
<script src="../_Templated.js"></script> | |
<script> | |
dojo.ready(function(){ | |
dojo.declare("my.Thinger", dojox.mustache._Widget, { | |
firstname:"dante", | |
lastname:"hicks", | |
templateString: dojo.cache("dojox.mustache.tests", "templates/whoami.html") | |
}); | |
var body = dojo.body(); | |
new my.Thinger().placeAt(body); | |
new my.Thinger({ firstname:"Peter", lastname:"Higgins" }).placeAt(body); | |
new my.Thinger({ | |
name: "Peter Higgins".split(" "), | |
lastname: function(){ | |
return this.name[1]; | |
}, | |
firstname: function(){ | |
return this.name[0]; | |
} | |
}).placeAt(body); | |
}); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Your name is: {{firstname}}, {{lastname}}</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment