Backbone, not "this.el" wrapping

Viewed 6475

I do an extensive use of templates, and I like to use full contained templates. I mean that I want to see in the template code all the DOM elements including the root one, like this:

<script type="text/template" id="template-card">
  <div class="card box" id="card-<%= id %>">
    <h2><%= title %></h2>
    <div><%= name %></div>
  </div>
</script>

But what Backbone likes is having a template like this:

<script type="text/template" id="template-card">
  <h2><%= title %></h2>
  <div><%= name %></div>
</script>

And defining the root element and its attributes in the JS code. What I think is ugly and confusing.

So, any good way to avoiding my Backbone View to wrapper my template with an extra DOM element?

I have been checking this issue thread: https://github.com/documentcloud/backbone/issues/546 and I understand there is not any official way to do it.. but maybe you can recommend me a non official way.

3 Answers
Related