Skip to content

Instantly share code, notes, and snippets.

@linus-amg
Created December 30, 2014 14:37
Show Gist options
  • Save linus-amg/aa0ebc415934ba17be52 to your computer and use it in GitHub Desktop.
Save linus-amg/aa0ebc415934ba17be52 to your computer and use it in GitHub Desktop.
Valid controller pattern for repetitive shows?
NavigationView = require 'views/navigation.coffee'
HomeView = require 'views/home.coffee'
OtherView = require 'views/other.coffee'
LogoutView = require 'views/logout.coffee'
ListView = require 'views/list/index.coffee'
TableView = require 'views/table/index.coffee'
ListCollection = require 'collections/list.coffee'
TableCollection = require 'collections/table.coffee'
module.exports = Marionette.Controller.extend
initialize: (options) ->
@App = options.App
displayNavigation: ->
@NavigationView = @NavigationView || new NavigationView
@App.header.show @NavigationView
home: ->
@displayNavigation()
@App.main.show new HomeView
other: ->
@displayNavigation()
@App.main.show new OtherView
logout: ->
@displayNavigation()
@App.main.show new LogoutView
list: ->
@displayNavigation()
@App.main.show new ListView
collection: new ListCollection
table: ->
@displayNavigation()
@App.main.show new TableView
collection: new TableCollection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment