Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor the skeleton. Use handlebars instead of eco.

  • Loading branch information...
commit 3058ad21ed6ba476d10dec309302691f13e0ad80 1 parent ccb9391
@paulmillr paulmillr authored
View
17 app/application.coffee
@@ -0,0 +1,17 @@
+# The application bootstrapper.
+Application =
+ initialize: ->
+ HomeView = require 'views/home_view'
+ Router = require 'lib/router'
+
+ # Ideally, initialized classes should be kept in controllers & mediator.
+ # If you're making big webapp, here's more sophisticated skeleton
+ # https://github.com/paulmillr/brunch-with-chaplin
+ @homeView = new HomeView()
+
+ # Instantiate the router
+ @router = new Router()
+ # Freeze the object
+ Object.freeze? this
+
+module.exports = Application
View
18 app/assets/humans.txt
@@ -1,18 +0,0 @@
-/* the humans responsible & colophon */
-/* humanstxt.org */
-
-
-/* TEAM */
- <your title>: <your name>
- Site:
- Twitter:
- Location:
-
-/* THANKS */
- Names (& URL):
-
-/* SITE */
- Standards: HTML5, CSS3
- Components: Brunch, Backbone.js, html5boilerplate, jQuery, Underscore.js,
- Stylus, eco
- Software: <list of tools you've used e.g. emacs>
View
0  app/collections/.gitkeep
No changes.
View
20 app/initialize.coffee
@@ -1,17 +1,5 @@
-MainRouter = require 'routers/main_router'
-HomeView = require 'views/home_view'
+application = require 'application'
-class exports.Application
- constructor: ->
- $ =>
- @initialize()
- Backbone.history.start()
-
- # This callback would be executed on document ready event.
- # If you have a big application, perhaps it's a good idea to
- # group things by their type e.g. `@views = {}; @views.home = new HomeView`.
- initialize: ->
- @router = new MainRouter
- @homeView = new HomeView
-
-window.app = new exports.Application
+$ ->
+ application.initialize()
+ Backbone.history.start()
View
8 app/lib/router.coffee
@@ -0,0 +1,8 @@
+application = require 'application'
+
+module.exports = class Router extends Backbone.Router
+ routes:
+ '': 'home'
+
+ home: ->
+ $('body').html application.homeView.render().el
View
1  app/lib/view_helper.coffee
@@ -0,0 +1 @@
+# Put your handlebars.js helpers here.
View
2  app/models/collection.coffee
@@ -0,0 +1,2 @@
+# Base class for all collections.
+module.exports = class Collection extends Backbone.Collection
View
2  app/models/model.coffee
@@ -0,0 +1,2 @@
+# Base class for all models.
+module.exports = class Model extends Backbone.Model
View
6 app/routers/main_router.coffee
@@ -1,6 +0,0 @@
-module.exports = class MainRouter extends Backbone.Router
- routes:
- '': 'home'
-
- home: ->
- $('body').html app.homeView.render().el
View
11 app/views/home_view.coffee
@@ -1,7 +1,6 @@
-module.exports = class HomeView extends Backbone.View
- id: 'home-view'
- template: require './templates/home'
+View = require './view'
+template = require './templates/home'
- render: ->
- @$el.html @template()
- this
+module.exports = class HomeView extends View
+ id: 'home-view'
+ template: template
View
0  app/views/templates/home.eco → app/views/templates/home.hbs
File renamed without changes
View
18 app/views/view.coffee
@@ -0,0 +1,18 @@
+require 'lib/view_helper'
+
+# Base class for all views.
+module.exports = class View extends Backbone.View
+ template: ->
+ return
+
+ getRenderData: ->
+ return
+
+ render: =>
+ # console.debug "Rendering #{@constructor.name}"
+ @$el.html @template @getRenderData()
+ @afterRender()
+ this
+
+ afterRender: ->
+ return
View
2  config.coffee
@@ -33,7 +33,7 @@ exports.config =
after: ['vendor/styles/helpers.css']
templates:
- defaultExtension: 'eco'
+ defaultExtension: 'hbs'
joinTo: 'javascripts/app.js'
# Change this if you're using something other than backbone (e.g. 'ember').
View
2  package.json
@@ -21,7 +21,7 @@
"css-brunch": "1.0.x || 1.1.x",
"stylus-brunch": "1.0.x || 1.1.x",
- "eco-brunch": "1.0.x || 1.1.x",
+ "handlebars-brunch": "1.0.x || 1.1.x",
"uglify-js-brunch": "1.0.x || 1.1.x",
"clean-css-brunch": "1.0.x || 1.1.x"
Please sign in to comment.
Something went wrong with that request. Please try again.