Created
November 17, 2014 21:44
-
-
Save lstebner/02501bf4e02a704da253 to your computer and use it in GitHub Desktop.
a basic coffeescript "View" class meant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class View | |
constructor: (container, @opts={}) -> | |
@default_opts() | |
@container = $ container | |
@setup() | |
default_opts: -> | |
@opts = _.extend( | |
{ | |
} | |
@opts | |
) | |
template_id: -> | |
"" | |
setup: -> | |
@setup_events() | |
@setup_template() | |
setup_events: -> | |
@container.on "click", (e) => | |
false | |
setup_template: -> | |
if @template_id().length | |
@template = _.template $(@template_id()).html() | |
view_data: -> | |
{} | |
render: -> | |
return unless @template | |
@container.empty() | |
@container.html @template @view_data() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment