mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
chore(generators): update page generator
This commit is contained in:
@ -1,36 +1,12 @@
|
|||||||
/*
|
|
||||||
ionic g page about
|
|
||||||
what should happen:
|
|
||||||
create directories if not existing: /www, /www/app, /www/app/about
|
|
||||||
create files (about.html, about.scss, about.js) in /www/app/about
|
|
||||||
*/
|
|
||||||
var fs = require('fs'),
|
|
||||||
Generator = module.exports,
|
|
||||||
Generate = require('../../generate'),
|
|
||||||
path = require('path'),
|
|
||||||
Q = require('q');
|
|
||||||
/*
|
|
||||||
Run: generate a page template from the name and save
|
|
||||||
it in the desired app directory
|
|
||||||
@options
|
|
||||||
name: Page name
|
|
||||||
appDirectory: App directory of where to save file
|
|
||||||
*/
|
|
||||||
Generator.run = function run(options) {
|
|
||||||
Generate.createScaffoldDirectories({appDirectory: options.appDirectory, componentDirectory: 'pages', fileName: options.fileName});
|
|
||||||
|
|
||||||
// Generate.defaultTemplates(options)
|
var path = require('path'),
|
||||||
options.rootDirectory = options.rootDirectory || path.join('app', 'pages');
|
Generator = require('../../generator');
|
||||||
var savePath = path.join(options.appDirectory, options.rootDirectory, options.fileName);
|
|
||||||
|
|
||||||
var templates = Generate.loadGeneratorTemplates(__dirname);
|
module.exports = PageGenerator;
|
||||||
|
|
||||||
templates.forEach(function(template) {
|
function PageGenerator(options) {
|
||||||
options.templatePath = template.file;
|
Generator.call(this, options);
|
||||||
var renderedTemplate = Generate.renderTemplateFromFile(options);
|
this.directory = path.join('app', 'pages');
|
||||||
var saveFilePath = path.join(savePath, [options.fileName, template.type].join(''));
|
}
|
||||||
// console.log('renderedTemplate', renderedTemplate, 'saving to', saveFilePath);
|
|
||||||
console.log('√ Create'.blue, path.relative(options.appDirectory, saveFilePath));
|
PageGenerator.prototype = Object.create(Generator.prototype);
|
||||||
fs.writeFileSync(saveFilePath, renderedTemplate);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
|
<!--
|
||||||
|
Generated template for the <%= jsClassName %> page.
|
||||||
|
|
||||||
|
See http://ionicframework.com/docs/v2/components/#navigation for more info on
|
||||||
|
Ionic pages and navigation.
|
||||||
|
-->
|
||||||
<ion-navbar *navbar>
|
<ion-navbar *navbar>
|
||||||
<ion-title><%= jsClassName %></ion-title>
|
<ion-title><%= jsClassName %></ion-title>
|
||||||
</ion-navbar>
|
</ion-navbar>
|
||||||
|
|
||||||
<ion-content padding class="<%= cssClassName %>">
|
<ion-content padding class="<%= fileName %>">
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import {Page, NavController} from 'ionic/ionic';
|
import {Page, NavController} from 'ionic/ionic';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generated class for the <%= jsClassName %> page.
|
||||||
|
|
||||||
|
See http://ionicframework.com/docs/v2/components/#navigation for more info on
|
||||||
|
Ionic pages and navigation.
|
||||||
|
*/
|
||||||
@Page({
|
@Page({
|
||||||
templateUrl: 'app/<%= fileName %>/<%= fileName %>.html',
|
templateUrl: '<%= directory %>/<%= fileName %>/<%= fileName %>.html',
|
||||||
})
|
})
|
||||||
export class <%= jsClassName %> {
|
export class <%= jsClassName %> {
|
||||||
constructor(nav: NavController) {
|
constructor(nav: NavController) {
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
.<%= cssClassName %> {
|
.<%= fileName %> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user