Permalink
Browse files

Refactor the skeleton. Use handlebars instead of eco.

  • Loading branch information...
1 parent 9cf4d75 commit 49c22edd1843e74cf8d92c7ce7410738f454c81c @paulmillr paulmillr committed Apr 1, 2012
View
15 app/application.js
@@ -0,0 +1,15 @@
+// Application bootstrapper.
+Application = {
+ initialize: function() {
+ var HomeView = require('views/home_view');
+ var 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
+ this.homeView = new HomeView();
+ this.router = new Router();
+ if (typeof Object.freeze === 'function') 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
25 app/initialize.js
@@ -1,21 +1,6 @@
-var MainRouter = require('routers/main_router');
-var HomeView = require('views/home_view');
+var application = require('application');
-exports.Application = (function() {
- function Application() {
- var _this = this;
- $(function() {
- _this.initialize();
- return Backbone.history.start();
- });
- }
-
- Application.prototype.initialize = function() {
- this.router = new MainRouter;
- return this.homeView = new HomeView;
- };
-
- return Application;
-})();
-
-window.app = new exports.Application;
+$(function() {
+ application.initialize();
+ Backbone.history.start();
+});
View
4 app/routers/main_router.js → app/lib/router.js
@@ -1,9 +1,11 @@
+var application = require('application');
+
module.exports = Backbone.Router.extend({
routes: {
'': 'home'
},
home: function() {
- $('body').html(app.homeView.render().el);
+ $('body').html(application.homeView.render().el);
}
});
View
1 app/lib/view_helper.js
@@ -0,0 +1 @@
+// Put your handlebars.js helpers here.
View
4 app/models/collection.js
@@ -0,0 +1,4 @@
+// Base class for all collections.
+module.exports = Backbone.Collection.extend({
+
+});
View
4 app/models/model.js
@@ -0,0 +1,4 @@
+// Base class for all models.
+module.exports = Backbone.Model.extend({
+
+});
View
10 app/views/home_view.js
@@ -1,7 +1,7 @@
-module.exports = Backbone.View.extend({
+var View = require('./view');
+var template = require('./templates/home');
+
+module.exports = View.extend({
id: 'home-view',
- render: function() {
- this.$el.html(require('./templates/home'));
- return this;
- }
+ template: template
});
View
2 app/views/templates/home.eco → app/views/templates/home.hbs
@@ -1,4 +1,3 @@
-<!-- START you can remove this -->
<div id="content">
<h1>brunch</h1>
<h2>Welcome!</h2>
@@ -8,4 +7,3 @@
<li><a href="https://github.com/brunch/todos">Todos Example App</a></li>
</ul>
</div>
-<!-- END you can remove this -->
View
19 app/views/view.js
@@ -0,0 +1,19 @@
+require('lib/view_helper');
+
+// Base class for all views.
+module.exports = Backbone.View.extend({
+ initialize: function() {
+ this.render = _.bind(this.render, this);
+ },
+
+ template: function() {},
+ getRenderData: function() {},
+
+ render: function() {
+ this.$el.html(this.template(this.getRenderData()));
+ this.afterRender();
+ return this;
+ },
+
+ afterRender: function() {}
+});
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
@@ -20,7 +20,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"

0 comments on commit 49c22ed

Please sign in to comment.