I'm using underscore.js for templating. Here is a sample template.
<script id="discussion-template" type="text/html">
[[ _.each(discussions, function(topic){ ]]
<li>
<article id="{{ topic.htmlId() }}">
<a class="section-arrow mir" href="#">toggle</a>
<h3>{{ topic.get('text') }}</h3>
<ol></ol>
</article>
</li>
[[ }); ]]
</script>
Inside a backbone.js view.render() I'm passing a collection to the template.
this.el.append(this.template({ discussions: this.collection.models }));
My question here is , do I have to write the looping code? Can I not just pass in a collection and underscore be smart enough to render one item per item in collection? Also does underscore.js provide something for nesting templates? Each item in the collection actually has a collection of items I will need to render as well. How can I call another template from within this template. Any links, tips, and or tutorials are of course greatly appreciated.
Thanks!