Skip to content

Instantly share code, notes, and snippets.

@planetoftheweb
Created November 14, 2012 02:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save planetoftheweb/4069805 to your computer and use it in GitHub Desktop.
Save planetoftheweb/4069805 to your computer and use it in GitHub Desktop.
Finished Mustache.js Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mustache Sample</title>
</head>
<body>
<h2>Titles</h2>
<ul id="talktitles">
</ul>
<script src="http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.7.0/mustache.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script id="speakers-template" type="text/template">
{{#speakers}}
<li>{{title}}</li>
{{/speakers}}
</script>
<script>
$(function() {
$.getJSON('http://barcampdeland.org/_/data/speakers.json', function(data) {
var template = $('#speakers-template').html();
var info = Mustache.to_html(template, data);
$('#talktitles').html(info);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment