Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2014 21:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save devdays/5917387995cb3b5eab3c to your computer and use it in GitHub Desktop.
Object JavaScript - Mustache Example
<!DOCTYPE html>
<div class="main-content">
<h1>All Products</h1>
<ul id="products"></ul>
<div id="sampleArea"></div>
<script src="Scripts/jquery-2.0.2.min.js"></script>
<script src="Scripts/mustache.js"></script>
var data = {
products: [
id: 1,
name: "Toy1",
category: "Toy",
price: 45.03,
freshness: new Date()
id: 2,
name: "Toy2",
category: "Toy",
price: 35.20,
freshness: new Date()
var template = "Products:<ul>{{#products}}" +
"<li>{{name}} {{category}} {{price}}</li>" +
var html = Mustache.to_html(template, data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment