Skip to content

Instantly share code, notes, and snippets.

@lstebner
Created November 17, 2014 21:44
Show Gist options
  • Save lstebner/02501bf4e02a704da253 to your computer and use it in GitHub Desktop.
Save lstebner/02501bf4e02a704da253 to your computer and use it in GitHub Desktop.
a basic coffeescript "View" class meant
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