From 2b27dea6cd2a336966cbf0040fb313bc5aae84d8 Mon Sep 17 00:00:00 2001 From: cueedee Date: Thu, 22 Dec 2016 15:09:39 +0100 Subject: [PATCH] feat(generators/app/templates): add automatic engagement of the Backbone-Debugger browser plugin when available Include automatically with debugging builds. --- README.md | 1 + generators/app/index.js | 1 + .../src/debug.backbone-debugger.coffee | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 generators/app/templates/src/debug.backbone-debugger.coffee diff --git a/README.md b/README.md index 8392cca8..b67bb913 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ The main app generator will provide you with the following out of the box: - [Grunt](http://gruntjs.com), or rather, a complete and annotated `Gruntfile.coffee`, set up for [Browserify](https://github.com/jmreidy/grunt-browserify#readme), [Compass](https://github.com/gruntjs/grunt-contrib-compass#readme), code [linting](https://github.com/vojtajina/grunt-coffeelint#readme), [-testing](https://github.com/pghalliday/grunt-mocha-test#readme), [-minification](https://github.com/gruntjs/grunt-contrib-uglify#readme) and [-documentation generation](https://github.com/gruntjs/grunt-contrib-yuidoc#readme); - [Browserify](http://browserify.org/), bundling modular code for the browser, supporting [CoffeeScript](https://github.com/jnordberg/coffeeify#readme), [Handlebars](https://github.com/epeli/node-hbsfy#readme) and [browserify shims](https://github.com/thlorenz/browserify-shim#readme); - [Backbone.js](http://backbonejs.org/) MV*x* foundation, including a main [router](http://backbonejs.org/#Router) implementation; +- [Backbone-Debugger](https://github.com/Maluen/Backbone-Debugger) browser plugin engagement (when available), automatically included with debugging builds; - [CoffeeScript](http://coffeescript.org/) coding; - [Compass](http://compass-style.org/) SASS styling; - [Handlebars](http://handlebarsjs.com/) HTML templating; diff --git a/generators/app/index.js b/generators/app/index.js index 0b6421b1..0d758980 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -446,6 +446,7 @@ var AppGenerator = generators.Base.extend( // App source for debug builds + , 'src/debug.backbone-debugger.coffee' , 'src/views/debug.environment-ribbon.coffee' , 'src/views/debug.environment-ribbon.hbs' diff --git a/generators/app/templates/src/debug.backbone-debugger.coffee b/generators/app/templates/src/debug.backbone-debugger.coffee new file mode 100644 index 00000000..68821451 --- /dev/null +++ b/generators/app/templates/src/debug.backbone-debugger.coffee @@ -0,0 +1,31 @@ +( ( factory ) -> + if typeof exports is 'object' + module.exports = factory( + require( 'backbone' ) + ) + else if typeof define is 'function' and define.amd + define( [ + 'backbone' + ], factory ) + return +)(( + Backbone +) -> + + ###* + # @author David Bouman + # @module App + ### + + 'use strict' + + + ## + ## Engage the [Backbone debugger browser plugin](https://github.com/Maluen/Backbone-Debugger#install-from-chrome-web-store) if present. + ## + + window.__backboneAgent?.handleBackbone( Backbone ) + + return + +)