Created
February 4, 2014 10:22
-
-
Save rahmanusta/8801172 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> | |
<meta name="description" content="Basic Handlebars App" /> | |
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="book" type="text/x-handlebars-template"> | |
<table class="table table-responsive table-bordered"> | |
<thead> | |
<tr> | |
<th>Book name</th> | |
<th>Book author</th> | |
<th>Book price</th> | |
</tr> | |
</thead> | |
<tbody> | |
{{#each this}} | |
<tr>{{> row}}</tr> | |
{{/each}} | |
</tbody> | |
</table> | |
</script> | |
<script id="row" type="text/x-handlebars-template"> | |
<td>{{name}}</td> | |
<td>{{author}}</td> | |
<td>{{price}}</td> | |
</script> | |
</body> | |
</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
var html = $("#book").html(); | |
var row = $("#row").html(); | |
var books = [ | |
{ | |
name:"Java ve Yazılım Tasarımı", | |
author:"Altuğ Altıntaş", | |
price:44 | |
}, | |
{ | |
name:"Java ve Yazılım Tasarımı", | |
author:"Altuğ Altıntaş", | |
price:33 | |
},{ | |
name:"Java ve Yazılım Tasarımı", | |
author:"Altuğ Altıntaş", | |
price:34 | |
}]; | |
var compiled = Handlebars.compile(html); | |
Handlebars.registerPartial("row", row); | |
var result = compiled(books); | |
console.log(result); | |
$("body").append(result); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment