Skip to content

Instantly share code, notes, and snippets.

@micahalles
Created July 11, 2011 03:16
Show Gist options
  • Save micahalles/1075275 to your computer and use it in GitHub Desktop.
Save micahalles/1075275 to your computer and use it in GitHub Desktop.
Functions
var comments = ["Sounds delicious!", "What next?!?"];
// or, if there are no comments
// var comments = [];
$("#my-template").expand({
content: "Step 1, light the grill. Step 2...",
comments: function(el) {
if (comments.length == 0) {
return false; // this will remove the comments div
} else {
return comments;
}
}
})
<div>
<span class="content">Step 1, light the grill. Step 2...</span>
<div class="comments">
<div class="comment">Sounds delicious!</div>
<div class="comment">What next?!?</div>
</div>
</div>
<div>
<span class="content">Step 1, light the grill. Step 2...</span>
</div>
<div id="my-template">
<span class="content"></span>
<div class="comments">
<div class="comment"></div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment