yeoman-blueprints
v1.0.6
Published
Extend yeoman.generators to add methods to interacting with local templates or blueprint
Downloads
22
Readme
yeoman-blueprints
For a working example look at generator-angular-blueprints.
Extends Yeoman's NamedBase to allow to your generator to use overridable templates. By using these extended methods yeoman will automatically check for locally created template under first ./blueprints and then ./node_modules before falling back to the global templates in the generator.
YOUR GENERATORS MUST BE UNDER generators/
npm install --save yeoman-blueprints
the generated folder structure for overriding blueprint
root
|-- blueprints
|---- templates
|------ blueprint.json
|------ controller
└-------- template.js
Methods
blueprints.copyTpl
// 'controller' - points to generator you want to use in this case located under generators/controller/
// 'js' - the file type to be created
// values - an object of values to be made available to template
this.copyTpl('controller', 'js', './destination/my-controller.js', values);
blueprints.copy
// 'controller' - points to generator you want to use in this case located under generators/controller/
// 'js' - the file type to be created
this.copy('view', 'html', './destination/my-view.html');
Example:
var blueprint = require('yeoman-blueprints');
module.exports = blueprints.NamedBase.extend({
writing: function writing() {
var destDir = './client/app/views/' + this.name + '.controller.js';
// Set the template values
var values = {value1: 'HelloWorld'}
// Create the template
this.copyTpl('controller', 'js', destDir, values);
}
});