UNPKG

creatable

Version:

Elegant HTML generation. No templating. Just Javascript.

46 lines (35 loc) 858 B
// Generated by CoffeeScript 1.4.0 /* Add support for Backbone Views to Creatable's rendering pipeline. */ /* Extend Backbone.View with a default render function that relies on build() to produce an s-exp representing the view. */ (function() { Backbone.View = Backbone.View.extend({ render: function() { var el, that; that = this; el = $(Creatable.create(this.build())); $(this.el).empty().append(el).fadeIn(); setTimeout((function() { return that.trigger("render", el); }), 0); return this; }, build: function() { return null; } }); /* Extend Creatable to support Backbone Views. */ Creatable.types.push({ isOfType: function(o) { return o instanceof Backbone.View; }, build: function(o) { return o.render().el; } }); }).call(this);