Last active
December 27, 2015 02:29
-
-
Save phillbaker/7252790 to your computer and use it in GitHub Desktop.
Rails + Backbone setup
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
mkdir -p app/assets/javascripts/backbone/lib/ \ | |
app/assets/javascripts/backbone/models/ \ | |
app/assets/javascripts/backbone/routers/ \ | |
app/assets/javascripts/backbone/templates/ \ | |
app/assets/javascripts/backbone/views/ | |
touch app/assets/javascripts/backbone/lib/.keep \ | |
app/assets/javascripts/backbone/models/.keep \ | |
app/assets/javascripts/backbone/routers/.keep \ | |
app/assets/javascripts/backbone/templates/.keep \ | |
app/assets/javascripts/backbone/views/.keep | |
mkdir -p vendor/assets/javascripts | |
curl http://backbonejs.org/backbone.js > vendor/assets/javascripts/backbone.js | |
curl http://underscorejs.org/underscore.js > vendor/assets/javascripts/underscore.js | |
touch app/assets/javascripts/backbone/[app_name].coffee |
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
... | |
//= require underscore | |
//= require backbone | |
//= require backbone/[app_name] | |
... |
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
#= require_self | |
#= require_tree ./lib | |
#= require_tree ./models | |
#= require_tree ./routers | |
#= require_tree ./templates | |
#= require_tree ./views | |
window.[app_name] = | |
Lib: {} | |
Models: {} | |
Collections: {} | |
Routers: {} | |
Views: {} |
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 [app_name].Models.[model] extends Backbone.Model | |
defaults: {} | |
class [app_name].Collections.[model] extends Backbone.Collection | |
model: [app_name].Models.[model] | |
url: '/path/to/model/json/api' |
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 [app_name].Routers.[router] extends Backbone.Router | |
initialize: (options) -> | |
routes: | |
"/path": "function" |
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 [app_name].Views.[view] extends Backbone.View | |
template: JST["template"] | |
events: {} | |
# "click .destroy" : "destroy" | |
initialize: (options) -> | |
@options ||= options | |
render: -> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/cc @ddgromit