mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
chore(generators): remove templateVars, pass 'this' instead
This commit is contained in:
@ -6,9 +6,13 @@ var _ = require('lodash'),
|
|||||||
module.exports = Generator;
|
module.exports = Generator;
|
||||||
|
|
||||||
function Generator(options) {
|
function Generator(options) {
|
||||||
this.name = _.kebabCase(options.name);
|
this.name = options.name;
|
||||||
this.type = options.generator;
|
this.type = options.generator;
|
||||||
this.appDirectory = options.appDirectory;
|
this.appDirectory = options.appDirectory;
|
||||||
|
|
||||||
|
//templateVars
|
||||||
|
this.fileName = _.kebabCase(this.name);
|
||||||
|
this.jsClassName = _.capitalize(_.camelCase(this.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
Generator.prototype.run = function(){
|
Generator.prototype.run = function(){
|
||||||
@ -53,14 +57,8 @@ Generator.prototype.loadTemplates = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Generator.prototype.renderTemplate = function(template) {
|
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 templateContents = fs.readFileSync(template.path, 'utf8');
|
||||||
var templateCompiler = _.template(templateContents);
|
var templateCompiler = _.template(templateContents);
|
||||||
var result = templateCompiler(templateVars);
|
var result = templateCompiler(this);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
@ -5,8 +5,9 @@
|
|||||||
Ionic pages and navigation.
|
Ionic pages and navigation.
|
||||||
-->
|
-->
|
||||||
<ion-navbar *navbar>
|
<ion-navbar *navbar>
|
||||||
<ion-title><%= jsClassName %></ion-title>
|
<ion-title><%= name %></ion-title>
|
||||||
</ion-navbar>
|
</ion-navbar>
|
||||||
|
|
||||||
<ion-content padding class="<%= fileName %>">
|
<ion-content padding class="<%= fileName %>">
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
Reference in New Issue
Block a user