grunt-bbamd_generate

Backbone AMD generator

grunt-bbamd_generate

Backbone AMD generator.

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-bbamd_generate --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-bbamd_generate');

In your project's Gruntfile, add a section named bbamd_generate to the data object passed into grunt.initConfig().

grunt.initConfig({
  bbamd_generate: {
    options: {
      appname    : "myAppName",
      source     : "myJsDirectory",
      mixins     : true,
      setAMDName : true
    },
    module:{},
    router:{},
    view:{},
    collection:{},
    model:{},
    template:{}
  },
})

Type: String Default value: 'app'

A string value that is used to...

Type: String Default value: 'js/backbone'

A string value that is used to...

Type: Boolean Default value: false

A boolean value that is used to...

Type: Boolean Default value: false

A boolean value that is used to...

grunt.initConfig({
  bbamd_generate: {
    options: {
      mixins     : true,
      setAMDName : true
    },
    module:{},
    router:{},
    view:{},
    collection:{},
    model:{},
    template:{}
  },
})
grunt bbamd_generate:module:post
 
define('modules/post',[
  'app',
  'underscore',
  'backbone',
  'mixins'
],
 
function(app_BackboneMixins){
 
  var Post = app.module();
 
  Post.Model = Backbone.Model.extend(_.extend({},
    // mixins 
    /* Mixins.Name, */ {
 
    // model properties  
    urlRoot: '',
    defaults: {}
  }));
 
  Post.Collection = Backbone.Collection.extend(_.extend({},
    // mixins 
    /* Mixins.Name, */ {
 
    // collection properties  
    url: '',
    model: Post.Model
  }));
 
  Post.Views.ModelView = Backbone.View.extend(_.extend({},
    // mixins 
    /* Mixins.Name, */ {
 
    // view properties  
    events: {},
    initializefunction() {},
    renderfunction() {
      return this;
    }
  }));
 
  Post.Views.CollectionView = Backbone.View.extend(_.extend({},
    // mixins 
    /* Mixins.Name, */ {
 
    // view properties  
    initializefunction(options) {
      this.collection.on('reset',this.render,this);
      this.collection.on('add',this.add,this);
    },
    renderfunction() {
      return this;
    },
    addfunction(model) {}
  }));
 
  return Post;
});
 

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

(Nothing yet)