Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As the manual said:</p> <blockquote> <p><strong>template</strong> </p> <p>_.template(templateString, [data], [settings])</p> <p>Compiles JavaScript templates into functions that can be evaluated for rendering.</p> <p>...you can pass the data object as the second parameter to template in order to render immediately instead of returning a template function.</p> </blockquote> <p>source: <a href="http://underscorejs.org/#template" rel="nofollow">http://underscorejs.org/#template</a></p> <p>So basically, <code>_.template()</code> take the html (template script) of the DOM element with id=<code>abc</code> defined somewhere in your DOM. Compile the data passed <code>that.model.attributes</code> and return the DOM part rendered and ready to be used. </p> <p>In case you're not passing the second argument <code>data</code> you'll get a template function to be used then, i.e:</p> <pre><code>var rendered = template({whatever: that.model.attributes}); </code></pre> <p><code>that.model.attributes</code> so <code>this.model.attributes</code> so (pseudo) <code>thisview.model.attributes</code> refers to model binded to this view. </p> <p><strong>Anyway, I suggest you to read</strong> </p> <ul> <li><p><a href="http://backbonejs.org/" rel="nofollow">http://backbonejs.org/</a></p></li> <li><p><a href="http://backbonejs.org/docs/backbone.html" rel="nofollow">http://backbonejs.org/docs/backbone.html</a></p></li> <li><p><a href="http://underscorejs.org/" rel="nofollow">http://underscorejs.org/</a></p></li> <li><p><a href="http://underscorejs.org/docs/underscore.html" rel="nofollow">http://underscorejs.org/docs/underscore.html</a></p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload