public
Created

plates nested objects

  • Download Gist
plates.expected.html
HTML
1 2 3 4 5 6 7 8 9
<div id="content">
<div class="date">Mon Mar 12 2012 23:08:16 GMT+0100 (CET)</div>
<div class="host">
<div class="name">Poland</div>
</div>
<div class="guest">
<div class="name">Greece</div>
</div>
</div>
plates.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<!DOCTYPE html>
<html>
<head>
<title>Plates testing</title>
<script type="text/javascript" src='public/javascripts/jquery-1.7.1.min.js'></script>
<script type="text/javascript" src='public/javascripts/plates.js'></script>
<script type="text/javascript">
 
$(document).ready(function () {
var tpl = $('#tpl').html();
 
var data = {
"date" : new Date().toString(),
"finals" : false,
"group" : "A",
"host" : { id: "pol_int", name: "Poland" },
"guest" : { id: "gre_int", name: "Greece" },
"points" : 0,
"score" : [ "2", "2" ],
"user" : "702185546"
};
 
var output = Plates.bind(tpl, data);
$('#content').html(output);
 
});
</script>
</head>
<body>
<div id="content"></div>
 
<div id="tpl" style="display:none;">
<div class="date"></div>
<div class="host">
<div class="name"></div>
</div>
<div class="guest">
<div class="name"></div>
</div>
</div>
</body>
</html>
plates.out.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12
<div id="content">
<div class="date">Mon Mar 12 2012 23:08:16 GMT+0100 (CET)</div>
<div class="host">
<div class="name">Poland</div>
</div>
<div class="guest">
<div class="name">Poland</div>
</div>
<div class="guest">
<div class="name">Greece</div>
</div>
</div>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.