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:
app
|_controllers/
|_user.js
|_user/
|_new.js
|_views/
|_user.js
|_routes/
|_user.js
|_user/
|_new.js
|_...
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; // get Ember global around for the templates; var routes = ;var App = ; AppRouter;// End template code // Start generated codeAppUserController = ;AppUserNewController = ;AppUserView = ;AppUserRoute = ;AppUserNewRoute = ;// 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).
Usage
Install:
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 = ;var 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
require('./.templates');
var routes = require('./config/routes');
var {{appName}} = require('./config/application');
{{appName}}.Router.map(routes);
{{#each helpers}}
require('{{path}}');{{/each}}
{{#each modules}}
{{../appName}}.{{name}} = require('{{path}}');{{/each}}
module.exports = {{appName}};
Via Grunt
// creates a file with requires for App.* for ember grunt;
Via Gulp
// creates a file with requires for App.* for embergulp;
Acknowledgment
The concept and some of the code comes from Ryan Florence's loom-ember.