Permalink
Browse files

updates and added in module

  • Loading branch information...
1 parent 1f5641d commit 8c9a74c516658cbe021dc0f5117ce627ea3623d1 @tbranyen tbranyen committed Jun 2, 2012
View
15 bbb.js
@@ -2,19 +2,10 @@ exports.description = "Backbone Boilerplate framework";
exports.notes = "This tool will help you install, configure, build, and "
+ "maintain your Backbone Boilerplate project.";
-exports.template = function(grunt, init, done) {
+// Any existing file or directory matching this wildcard will cause a warning.
+exports.warnOn = "*";
- // Grunt utilities.
- var task = grunt.task;
- var file = grunt.file;
- var utils = grunt.utils;
- var log = grunt.log;
- var verbose = grunt.verbose;
- var fail = grunt.fail;
- var option = grunt.option;
- var config = grunt.config;
- var template = grunt.template;
- var _ = grunt.utils._;
+exports.template = function(grunt, init, done) {
// Files to copy (and process).
var files = init.filesToCopy({});
View
@@ -0,0 +1,30 @@
+exports.description = "BBB: Add new module";
+exports.notes = "Generates a new module";
+
+exports.template = function(grunt, init, done) {
+
+ grunt.helper("prompt", {}, [
+
+ // Get the name of the module.
+ grunt.helper("prompt_for", "name", function(value, data, done) {
+ // Flatten the module name.
+ value = value.toLowerCase();
+
+ // Set the module name to be the title case.
+ data.module_name = value[0].toUpperCase() + value.slice(1);
+
+ done(null, value);
+ }),
+
+ ], function(err, props) {
+ // Files to copy (and process).
+ var files = init.filesToCopy(props);
+
+ // Actually copy (and process) files.
+ init.copyAndProcess(files, props, {});
+
+ // All done!
+ done();
+ });
+
+};
View
@@ -0,0 +1,3 @@
+{
+ "app/modules/name.js": "app/modules/{%= name %}.js"
+}
@@ -0,0 +1,18 @@
+define([
+ // Global application context.
+ "app",
+
+ // Third-party libraries.
+ "backbone"
+],
+
+function(app, Backbone) {
+ var {%= name %} = app.module();
+
+ {% if (placeholders) { %}
+ {%= name %}.Model = Backbone.Model.extend({});
+ {%= name %}.Collection = Backbone.Model.extend({});
+ {% } %}
+
+ return {%= name %};
+});
View
@@ -4,18 +4,6 @@ exports.notes = "Generates the TodoMVC application using " +
exports.template = function(grunt, init, done) {
- // Grunt utilities.
- var task = grunt.task;
- var file = grunt.file;
- var utils = grunt.utils;
- var log = grunt.log;
- var verbose = grunt.verbose;
- var fail = grunt.fail;
- var option = grunt.option;
- var config = grunt.config;
- var template = grunt.template;
- var _ = grunt.utils._;
-
// Files to copy (and process).
var files = init.filesToCopy({});
View
@@ -10,31 +10,24 @@ require.config({
// Libraries
jquery: "../assets/js/libs/jquery",
- underscore: "../assets/js/libs/underscore",
- backbone: "../assets/js/libs/backbone",
-
- // Shim Plugin
- use: "../assets/js/plugins/use"
+ lodash: "../assets/js/libs/lodash",
+ backbone: "../assets/js/libs/backbone"
},
- use: {
+ shim: {
backbone: {
- deps: ["use!underscore", "jquery"],
+ deps: ["lodash", "jquery"],
attach: "Backbone"
},
- underscore: {
- attach: "_"
- },
-
// Add the Backbone LocalStorage plugin in
"plugins/backbone-localstorage": {
- deps: ["use!backbone"]
+ deps: ["backbone"]
},
// Add the Backbone LocalStorage plugin in
"plugins/backbone.layoutmanager": {
- deps: ["use!backbone"]
+ deps: ["backbone"]
}
}
});
View
@@ -3,7 +3,7 @@ require([
// Libs
"jquery",
- "use!backbone",
+ "backbone",
// Modules
"modules/todo"
@@ -2,13 +2,13 @@ define([
"namespace",
// Libs
- "use!backbone",
+ "backbone",
// Views
"modules/todo/views",
// Plugins
- "use!plugins/backbone-localstorage"
+ "plugins/backbone-localstorage"
],
function(namespace, Backbone, Views) {
@@ -86,7 +86,6 @@ function(namespace, Backbone, Views) {
}
});
-
// Todo Views
// ----------
@@ -2,7 +2,7 @@ define([
"namespace",
// Libs
- "use!backbone"
+ "backbone"
],
function(namespace, Backbone) {
@@ -81,15 +81,13 @@ function(namespace, Backbone) {
tagName: "ul",
render: function(manage) {
- var view = manage(this);
-
this.collection.each(function(item) {
- view.insert(new Views.Item({
+ this.insertView(new Views.Item({
model: item
}));
- });
+ }, this);
- return view.render();
+ return manage(this).render();
},
initialize: function() {
@@ -98,9 +96,9 @@ function(namespace, Backbone) {
}, this);
this.collection.on("add", function(item) {
- this.view(new Views.Item({
+ this.insertView(new Views.Item({
model: item
- }), true).render();
+ })).render();
}, this);
}
});
@@ -1,40 +1,34 @@
define([
// Libs
"jquery",
- "use!underscore",
- "use!backbone",
+ "lodash",
+ "backbone",
// Plugins
- "use!plugins/backbone.layoutmanager"
+ "plugins/backbone.layoutmanager"
],
function($, _, Backbone) {
- // Put application wide code here
+ // Create or attach to the global JavaScript Template cache.
+ var JST = window.JST = window.JST || {};
+
+ // Configure LayoutManager
Backbone.LayoutManager.configure({
paths: {
layout: "app/templates/layouts/",
template: "app/templates/"
},
- render: function(template, context) {
- return template(context);
- },
-
fetch: function(path) {
path = path + ".html";
- var done = this.async();
- var JST = window.JST = window.JST || {};
-
- if (JST[path]) {
- return done(JST[path]);
+ if (!JST[path]) {
+ $.ajax({ url: path, async: false }).then(function(contents) {
+ JST[path] = _.template(contents);
+ });
}
- $.get(path, function(contents) {
- var tmpl = _.template(contents);
-
- done(JST[path] = tmpl);
- }, "text");
+ return done(JST[path]);
}
});
Oops, something went wrong.

0 comments on commit 8c9a74c

Please sign in to comment.