diff --git a/addon/ng2/blueprints/component/files/__path__/__name__.component.ts b/addon/ng2/blueprints/component/files/__path__/__name__.component.ts index 47942d9ca32a..4e72bbb8b1e0 100644 --- a/addon/ng2/blueprints/component/files/__path__/__name__.component.ts +++ b/addon/ng2/blueprints/component/files/__path__/__name__.component.ts @@ -3,9 +3,16 @@ import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from 'angular2/router' @Component({ moduleId: __moduleName, - selector: '<%= dasherizedModuleName %>', - templateUrl: '<%= dasherizedModuleName %>.component.html', - styleUrls: ['<%= dasherizedModuleName %>.component.<%= styleExt %>']<% if (route) { %>, + selector: '<%= dasherizedModuleName %>',<% if(inlineTemplate) { %> + template: ` +

+ <%= dasherizedModuleName %> Works! +

<% if (route) { %> + <% } %> + `,<% } else { %> + templateUrl: '<%= dasherizedModuleName %>.component.html',<% } if(inlineStyle) { %> + styles: []<% } else { %> + styleUrls: ['<%= dasherizedModuleName %>.component.<%= styleExt %>']<% } if (route) { %>, directives: [ROUTER_DIRECTIVES]<% } %> })<% if (route) { %> @RouteConfig([ diff --git a/addon/ng2/blueprints/component/index.js b/addon/ng2/blueprints/component/index.js index 6c45b7eaac40..9fa10decfa0b 100644 --- a/addon/ng2/blueprints/component/index.js +++ b/addon/ng2/blueprints/component/index.js @@ -20,7 +20,9 @@ module.exports = { availableOptions: [ { name: 'flat', type: Boolean, default: false }, - { name: 'route', type: Boolean, default: false } + { name: 'route', type: Boolean, default: false }, + { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] }, + { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] } ], normalizeEntityName: function (entityName) { @@ -42,6 +44,8 @@ module.exports = { return { dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''), flat: options.flat, + inlineTemplate: options.inlineTemplate, + inlineStyle: options.inlineStyle, route: options.route, styleExt: this.styleExt, isLazyRoute: !!options.isLazyRoute, @@ -58,6 +62,12 @@ module.exports = { if (this.options && !this.options.route) { fileList = fileList.filter(p => p.indexOf(path.join('shared', 'index.ts')) <= 0); } + if (this.options && this.options.inlineTemplate) { + fileList = fileList.filter(p => p.indexOf('.html') < 0); + } + if (this.options && this.options.inlineStyle) { + fileList = fileList.filter(p => p.indexOf('.__styleext__') < 0); + } return fileList; }, diff --git a/addon/ng2/blueprints/route/index.js b/addon/ng2/blueprints/route/index.js index 8f444df435ec..4c4f776106db 100644 --- a/addon/ng2/blueprints/route/index.js +++ b/addon/ng2/blueprints/route/index.js @@ -13,7 +13,9 @@ module.exports = { availableOptions: [ { name: 'skip-router-generation', type: Boolean, default: false, aliases: ['srg'] }, { name: 'default', type: Boolean, default: false }, - { name: 'lazy', type: Boolean, default: true } + { name: 'lazy', type: Boolean, default: true }, + { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] }, + { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] } ], beforeInstall: function(options) { diff --git a/tests/acceptance/generate-component.spec.js b/tests/acceptance/generate-component.spec.js index 204f17a0eb9a..896c4c12c713 100644 --- a/tests/acceptance/generate-component.spec.js +++ b/tests/acceptance/generate-component.spec.js @@ -159,4 +159,18 @@ describe('Acceptance: ng generate component', function () { expect(existsSync(testPath)).to.equal(true); }); }); + + it('ng generate component my-comp --inline-template', function () { + return ng(['generate', 'component', 'my-comp', '--inline-template']).then(() => { + var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', 'my-comp', 'my-comp.component.html'); + expect(existsSync(testPath)).to.equal(false); + }); + }); + + it('ng generate component my-comp --inline-style', function () { + return ng(['generate', 'component', 'my-comp', '--inline-style']).then(() => { + var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', 'my-comp', 'my-comp.component.css'); + expect(existsSync(testPath)).to.equal(false); + }); + }); });