In handlebars i need to check if an object is empty and if it isn't then i need to run a loop to grab the content from the object. Below is my code and a link to codepen. I imagine this is quite simple but nothing seems to work. I would have thought that the handlebars #if statement would see an empty object as undefined or 0 and ultimately the condition would be unfulfilled.
<div class="temp"></div>
<script id="temp" type="x-handlebars-template">
{{#if tabs}}
<p>true</p>
{{/if}}
</script>
var template = Handlebars.compile($("#temp").html());
var tabs = {};
var context = {
tabs: tabs
}
$('.temp').html(template(context));
Aucun commentaire:
Enregistrer un commentaire