mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
chore(generators): remove templateVars, pass 'this' instead
This commit is contained in:
@ -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;
|
||||
};
|
@ -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>
|
||||
|
Reference in New Issue
Block a user