balderdashy / mast

UI conventions built on top of Backbone.JS
MIT License
81 stars 14 forks source link

Use Backbone to generate $el #103

Closed particlebanana closed 11 years ago

particlebanana commented 11 years ago

Backbone has an _ensureElement method that it uses to create the el context. Instead of just wrapping a template in a div, just use the method from Backbone.

This gives us all the options that Backbone.View has such as:

I had to override the Backbone method because each Component has an id so the normal _ensureElement will give every component's view an id. This would be an issue if you want to use a component multiple times.

It should allow this:

Mast.define('componentName', function() {
  return {
    tagName: 'ul',
    className: 'user'
  }
});

Which generates a normal backbone view el:

<ul class="user"></ul>

Works in my tests but I want to make sure someone else looks it over. Still wrapping my head around the library.