Skip to content

Instantly share code, notes, and snippets.

@rahmanusta
Created February 4, 2014 16:51
Show Gist options
  • Save rahmanusta/8807613 to your computer and use it in GitHub Desktop.
Save rahmanusta/8807613 to your computer and use it in GitHub Desktop.
<!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>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<meta name="description" content="Handlebars SubContext3UNLESS" />
<meta charset=utf-8 />
<title>Handlebars SubContext3UNLESS</title>
</head>
<body>
<script id="book" type="text/x-handlebars-template">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
{{name}} / <b>{{author}}</b> / {{price}}
</h3>
</div>
<div class="panel-body">
<ul>
{{#each this.content}}
{{#unless .}}
<li>{{.}}</li>
{{/unless}}
{{/each}}
</ul>
</div>
</div>
</script>
</body>
</html>
var book = {
name:"Java ve Yazılım Tasarımı",
author:"Altuğ B. Altıntaş",
price:34,
content:[]
};
book.content.push("Kalıtım");
book.content.push(undefined);
book.content.push("MultiThreading");
book.content.push(null);
book.content.push("Çokyüzlülük");
book.content.push(0);
book.content.push("Ağ programlama");
book.content.push(false);
var template = $("#book").html();
var compiled = Handlebars.compile(template);
var result = compiled(book);
$("body").append(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment