Sha256: 9374bfbe2c7f15e39fed6c3963823814ede77907cc456f7a4d4642094f7e946a

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

class <%= router_namespace %>Router extends Backbone.Router
  initialize: (options) ->
    @<%= plural_model_name %> = new <%= collection_namespace %>Collection()
    @<%= plural_model_name %>.reset options.<%= plural_model_name %>

  routes:
    "new"      : "new<%= class_name %>"
    "index"    : "index"
    ":id/edit" : "edit"
    ":id"      : "show"
    ".*"        : "index"

  new<%= class_name %>: ->
    @view = new <%= "#{view_namespace}.NewView(collection: @#{plural_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

  index: ->
    @view = new <%= "#{view_namespace}.IndexView(collection: @#{plural_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

  show: (id) ->
    <%= singular_name %> = @<%= plural_name %>.get(id)

    @view = new <%= "#{view_namespace}.ShowView(model: #{singular_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

  edit: (id) ->
    <%= singular_name %> = @<%= plural_name %>.get(id)

    @view = new <%= "#{view_namespace}.EditView(model: #{singular_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
bbr-wsm-1.1.0 lib/generators/backbone/scaffold/templates/router.coffee
rails-backbone-1.2.0 lib/generators/backbone/scaffold/templates/router.coffee
railsy_backbone-0.0.5 lib/generators/backbone/scaffold/templates/router.coffee