Sha256: b2af56b5b47ac998f3b6e5acf0f84adf181189c09c59da36bc879996c7f5e2b8

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 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:
    "/<%= plural_name %>/new"      : "new<%= class_name %>"
    "/<%= plural_name %>/index"    : "index"
    "/<%= plural_name %>/:id/edit" : "edit"
    "/<%= plural_name %>/:id"      : "show"
    "/<%= plural_name %>/.*"       : "index"
  
  new<%= class_name %>: ->
    @view = new <%= "#{view_namespace}.NewView(collection: @#{plural_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

  index: ->
    @view = new <%= "#{view_namespace}.IndexView(#{plural_name}: @#{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

1 entries across 1 versions & 1 rubygems

Version Path
rails-backbone-sp-0.0.1 lib/generators/backbone/scaffold/templates/router-sp.coffee