chore(generators): remove templateVars, pass 'this' instead

This commit is contained in:
Tim Lancina
2016-01-07 18:57:57 -06:00
parent 44be634997
commit d7b639e13b
2 changed files with 8 additions and 9 deletions

View File

@ -6,9 +6,13 @@ var _ = require('lodash'),
module.exports = Generator;
function Generator(options) {
this.name = _.kebabCase(options.name);
this.name = options.name;
this.type = options.generator;
this.appDirectory = options.appDirectory;
//templateVars
this.fileName = _.kebabCase(this.name);
this.jsClassName = _.capitalize(_.camelCase(this.name));
}
Generator.prototype.run = function(){
@ -53,14 +57,8 @@ Generator.prototype.loadTemplates = function() {
};
Generator.prototype.renderTemplate = function(template) {
var templateVars = {
fileName: _.kebabCase(this.name),
directory: this.directory,
jsClassName: _.capitalize(_.camelCase(this.name))
}
var templateContents = fs.readFileSync(template.path, 'utf8');
var templateCompiler = _.template(templateContents);
var result = templateCompiler(templateVars);
var result = templateCompiler(this);
return result;
};

View File

@ -5,8 +5,9 @@
Ionic pages and navigation.
-->
<ion-navbar *navbar>
<ion-title><%= jsClassName %></ion-title>
<ion-title><%= name %></ion-title>
</ion-navbar>
<ion-content padding class="<%= fileName %>">
</ion-content>