Ember Stream Generator

This generator set is used to create an CJS require hierarchy for an EmberJS project structure. The main use-case, is for use with Browserify.
For example, given the following structure:


This generator set can be used to generate a file, along the lines of .index.js, with the following contents:

// Start template code: Generated from template 
require('ember'); // get Ember global around for the templates 
var routes = require('./config/routes');
var App = require('./config/application');
// End template code 
// Start generated code 
App.UserController = require('./controllers/user');
App.UserNewController = require('./controllers/user/new');
App.UserView = require('./views/user');
App.UserRoute = require('./routes/user');
App.UserNewRoute = require('./routes/user/new');
// more ... 

Note: The config directory is required, with the application definition in config/application.js and the router definition in config/routes.js. This also requires a .templates.js file in the root directory (this is a precompiled templates file, see ember-template-compiler).


npm install ember-stream-generator --save

Available Options:

This stream takes three options stream(path, appName, customTemplatePath).

  • path - The path to the root of you client directory.
  • appName - Name of your Ember.Application instance, e.g. App.UserRoute.
  • customTemplatePath - Path to custom template, the default template is below.

Basic Example:

This stream should be used with other streams:

var esg = require('ember-stream-generator');
var fs = require('fs');

Default Template:

If no template path is given, this is the default:

// this file is auto-generated, do not edit
require('ember'); // get Ember global around for the templates
var routes = require('./config/routes');
var {{appName}} = require('./config/application');
{{#each helpers}}
{{#each modules}}
{{../appName}}.{{name}} = require('{{path}}');{{/each}}
module.exports = {{appName}};
  // creates a file with requires for App.* for ember 
  grunt.registerTask('pre-browserify', function () {
    var done = this.async();
    var emberStream = require('ember-stream-generator');
    var fs = require('fs');
    var inStream = emberStream('./client');
    var outStream = fs.createWriteStream('./client/.index.js');
    outStream.on('finish', done);
// creates a file with requires for App.* for ember 
gulp.task('pre-browserify', function () {
  var emberStream = require('ember-stream-generator');
  var rename = require('gulp-rename');
  var source = require('vinyl-source-stream');
  var clientPath = './client/';

The concept and some of the code comes from Ryan Florence's loom-ember.