Created
July 27, 2012 18:16
-
-
Save maxbeatty/3189524 to your computer and use it in GitHub Desktop.
Sample Mustache templates
This file contains 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
<div id="mustacheContainer"></div> |
This file contains 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
// json1.js | |
var user = { | |
fname:'joe', | |
lname:'blogs', | |
} | |
// json2.js | |
var translations = { | |
someword:'its translation' | |
} | |
// test.mustache => https://gist.github.com/3189524 | |
var extension = "html", | |
gistID = '3189524', | |
testMustacheGist = "/gh/gist/response." + extension + "/" + gistID + "/" | |
/* | |
$.get(testMustacheGist, function(templates) { | |
var template = $(templates).filter('#tpl-one').html(); | |
$.extend(json1, json2); | |
var three = $(templates).filter('#tpl-three').html(); | |
three = { | |
"tplThree": one | |
}; | |
var html = Mustache.to_html(template, json1, three); | |
$('#confirmationMustacheContainer').html(html); | |
console.log(templates); | |
$('#mustacheContainer').text(templates); | |
}, extension); */ | |
$.ajax({ | |
url: testMustacheGist, | |
success: function(data, status, jqXHR) { | |
console.log(data, status, jqXHR); | |
}, | |
dataType: 'html' | |
}); |
This file contains 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
<script id="tpl-one" type="text/html"><!--main template --> | |
{{fname}} | |
{{> tplThree}} | |
</script> | |
<script id="tpl-two" type="text/html"> | |
{{lname}} | |
</script> | |
<script id="tpl-three" type="text/html"> | |
{{> tplTwo}} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment