forked from tastejs/todomvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tastejs#578 from stephenplusplus/canjs_require
restructured canjs_require + code style.
- Loading branch information
Showing
4 changed files
with
70 additions
and
49 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
/*global require*/ | ||
/*global require */ | ||
require.config({ | ||
paths: { | ||
jquery: '../bower_components/jquery/jquery', | ||
can: '../bower_components/CanJS/amd/can' | ||
} | ||
}); | ||
|
||
require(['can/util/library', 'can/route', 'app/todos', 'app/models/todo', 'can/view/ejs', 'can/view/mustache'], | ||
function (can, route, Todos, Model) { | ||
'use strict'; | ||
require([ | ||
'can/util/library', | ||
'can/route', | ||
'controls/todos', | ||
'models/todo', | ||
'can/view/ejs', | ||
'can/view/mustache' | ||
], function (can, route, Todos, Model) { | ||
'use strict'; | ||
|
||
// Set up a route that maps to the `filter` attribute | ||
route(':filter'); | ||
// Delay routing until we initialized everything | ||
route.ready(false); | ||
// Set up a route that maps to the `filter` attribute | ||
route(':filter'); | ||
// Delay routing until we initialized everything | ||
route.ready(false); | ||
|
||
// View helper for pluralizing strings | ||
can.Mustache.registerHelper('todoPlural', function (str, attr) { | ||
return str + (attr.call(this.todos) !== 1 ? 's' : ''); | ||
}); | ||
// View helper for pluralizing strings | ||
can.Mustache.registerHelper('todoPlural', function (str, attr) { | ||
return str + (attr.call(this.todos) !== 1 ? 's' : ''); | ||
}); | ||
|
||
// Find all Todos | ||
Model.findAll({}, function (todos) { | ||
// Wire it up. Instantiate a new Todos control | ||
new Todos('#todoapp', { | ||
// The (Todo) model that the control should use | ||
Model: Model, | ||
// The list of Todos retrieved from the model | ||
todos: todos, | ||
// The control state for filtering the view (in our case the router) | ||
state: can.route, | ||
// The view to render | ||
view: 'views/todos.mustache' | ||
}); | ||
// Find all Todos | ||
Model.findAll({}, function (todos) { | ||
// Wire it up. Instantiate a new Todos control | ||
new Todos('#todoapp', { | ||
// The (Todo) model that the control should use | ||
Model: Model, | ||
// The list of Todos retrieved from the model | ||
todos: todos, | ||
// The control state for filtering the view (in our case the router) | ||
state: can.route, | ||
// The view to render | ||
view: 'views/todos.mustache' | ||
}); | ||
|
||
// Now we can start routing | ||
route.ready(true); | ||
}); | ||
|
||
// Now we can start routing | ||
route.ready(true); | ||
}); |
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
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
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