Skip to content

Commit 90615a8

Browse files
committed
fix(@schematics/angular): default component templates to not use .ng.html extension
To align with recent changes to the updated style guide, Angular v20 will now generate component templates without a `.ng.html` file extension and instead use the previous `.html` by default. The `--ng-html` option is still available for use if the `.ng.html` extension is preferred in projects.
1 parent 070d60f commit 90615a8

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

packages/schematics/angular/application/files/module-files/src/app/app.ts.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Component } from '@angular/core';
99
%><router-outlet /><%
1010
} %>
1111
`,<% } else { %>
12-
templateUrl: './app.ng.html',<% } %>
12+
templateUrl: './app.html',<% } %>
1313
standalone: false,<% if(inlineStyle) { %>
1414
styles: []<% } else { %>
1515
styleUrl: './app.<%= style %>'<% } %>

packages/schematics/angular/application/files/standalone-files/src/app/app.ts.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { RouterOutlet } from '@angular/router';<% } %>
1111
%><router-outlet /><%
1212
} %>
1313
`,<% } else { %>
14-
templateUrl: './app.ng.html',<% } if(inlineStyle) { %>
14+
templateUrl: './app.html',<% } if(inlineStyle) { %>
1515
styles: [],<% } else { %>
1616
styleUrl: './app.<%= style %>'<% } %>
1717
})

packages/schematics/angular/application/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default function (options: ApplicationOptions): Rule {
8484
? filter((path) => !path.endsWith('tsconfig.spec.json.template'))
8585
: noop(),
8686
componentOptions.inlineTemplate
87-
? filter((path) => !path.endsWith('.ng.html.template'))
87+
? filter((path) => !path.endsWith('app.html.template'))
8888
: noop(),
8989
applyTemplates({
9090
utils: strings,

packages/schematics/angular/application/index_spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('Application Schematic', () => {
5656
'/projects/foo/src/styles.css',
5757
'/projects/foo/src/app/app-module.ts',
5858
'/projects/foo/src/app/app.css',
59-
'/projects/foo/src/app/app.ng.html',
59+
'/projects/foo/src/app/app.html',
6060
'/projects/foo/src/app/app.spec.ts',
6161
'/projects/foo/src/app/app.ts',
6262
]),
@@ -266,7 +266,7 @@ describe('Application Schematic', () => {
266266
'/src/main.ts',
267267
'/src/styles.css',
268268
'/src/app/app.css',
269-
'/src/app/app.ng.html',
269+
'/src/app/app.html',
270270
'/src/app/app.spec.ts',
271271
'/src/app/app.ts',
272272
]),
@@ -447,7 +447,7 @@ describe('Application Schematic', () => {
447447
[
448448
'/projects/foo/tsconfig.spec.json',
449449
'/projects/foo/src/app/app.css',
450-
'/projects/foo/src/app/app.ng.html',
450+
'/projects/foo/src/app/app.html',
451451
'/projects/foo/src/app/app.spec.ts',
452452
].forEach((x) => expect(files).not.toContain(x));
453453

@@ -472,7 +472,7 @@ describe('Application Schematic', () => {
472472
'/projects/foo/tsconfig.spec.json',
473473
'/projects/foo/karma.conf.js',
474474
'/projects/foo/src/test.ts',
475-
'/projects/foo/src/app/app.ng.html',
475+
'/projects/foo/src/app/app.html',
476476
'/projects/foo/src/app/app.spec.ts',
477477
].forEach((x) => expect(files).not.toContain(x));
478478

@@ -509,7 +509,7 @@ describe('Application Schematic', () => {
509509
'/projects/foo/src/index.html',
510510
'/projects/foo/src/main.ts',
511511
'/projects/foo/src/styles.css',
512-
'/projects/foo/src/app/app.ng.html',
512+
'/projects/foo/src/app/app.html',
513513
'/projects/foo/src/app/app.ts',
514514
]),
515515
);
@@ -531,7 +531,7 @@ describe('Application Schematic', () => {
531531
'/projects/foo/src/styles.css',
532532
'/projects/foo/src/app/app.config.ts',
533533
'/projects/foo/src/app/app.css',
534-
'/projects/foo/src/app/app.ng.html',
534+
'/projects/foo/src/app/app.html',
535535
'/projects/foo/src/app/app.spec.ts',
536536
'/projects/foo/src/app/app.ts',
537537
]),
@@ -672,7 +672,7 @@ describe('Application Schematic', () => {
672672
'/projects/foo/src/app/app-routing-module.ts',
673673
'/projects/foo/src/app/app-module.ts',
674674
'/projects/foo/src/app/app.css',
675-
'/projects/foo/src/app/app.ng.html',
675+
'/projects/foo/src/app/app.html',
676676
'/projects/foo/src/app/app.spec.ts',
677677
'/projects/foo/src/app/app.ts',
678678
]),

packages/schematics/angular/component/index_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ describe('Component Schematic', () => {
310310
expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.ng.html');
311311
});
312312

313-
it('should use `.ng.html` extension when ngHtml is not present', async () => {
313+
it('should not use `.ng.html` extension when ngHtml is not present', async () => {
314314
const options = { ...defaultOptions, ngHtml: undefined };
315315
const tree = await schematicRunner.runSchematic('component', options, appTree);
316316
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
317-
expect(content).toContain('foo.component.ng.html');
317+
expect(content).toContain('foo.component.html');
318318
expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.css');
319-
expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.ng.html');
319+
expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.html');
320320
});
321321

322322
it('should create the right selector with a path in the name', async () => {

packages/schematics/angular/component/schema.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@
137137
},
138138
"ngHtml": {
139139
"type": "boolean",
140-
"default": true,
141-
"description": "Generate component template files with an '.ng.html' file extension instead of '.html'. The '.ng.html' file extension is recommended by the Angular style guide."
140+
"default": false,
141+
"description": "Generate component template files with an '.ng.html' file extension instead of '.html'."
142142
}
143143
},
144144
"required": ["name", "project"]

packages/schematics/angular/module/index_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('Module Schematic', () => {
153153
'/projects/bar/src/app/foo/foo-module.ts',
154154
'/projects/bar/src/app/foo/foo-routing-module.ts',
155155
'/projects/bar/src/app/foo/foo.ts',
156-
'/projects/bar/src/app/foo/foo.ng.html',
156+
'/projects/bar/src/app/foo/foo.html',
157157
'/projects/bar/src/app/foo/foo.css',
158158
]),
159159
);
@@ -203,7 +203,7 @@ describe('Module Schematic', () => {
203203
expect(files).toContain('/projects/bar/src/app/foo/foo-module.ts');
204204
expect(files).not.toContain('/projects/bar/src/app/foo/foo-routing-module.ts');
205205
expect(files).toContain('/projects/bar/src/app/foo/foo.ts');
206-
expect(files).toContain('/projects/bar/src/app/foo/foo.ng.html');
206+
expect(files).toContain('/projects/bar/src/app/foo/foo.html');
207207
expect(files).toContain('/projects/bar/src/app/foo/foo.css');
208208

209209
const appModuleContent = tree.readContent('/projects/bar/src/app/app-module.ts');
@@ -231,7 +231,7 @@ describe('Module Schematic', () => {
231231
'/projects/bar/src/app/foo-module.ts',
232232
'/projects/bar/src/app/foo-routing-module.ts',
233233
'/projects/bar/src/app/foo.ts',
234-
'/projects/bar/src/app/foo.ng.html',
234+
'/projects/bar/src/app/foo.html',
235235
'/projects/bar/src/app/foo.css',
236236
]),
237237
);

0 commit comments

Comments
 (0)