-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Angular inline styles as single template literal (#15968)
- Loading branch information
1 parent
4b1965a
commit 2fe7f41
Showing
5 changed files
with
231 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#### Support Angular inline styles as single template literal (#15968 by @sosukesuzuki) | ||
|
||
[Angular v17](https://blog.angular.io/introducing-angular-v17-4d7033312e4b) supports single string inline styles. | ||
|
||
<!-- prettier-ignore --> | ||
```ts | ||
// Input | ||
@Component({ | ||
template: `<div>...</div>`, | ||
styles: `h1 { color: blue; }`, | ||
}) | ||
export class AppComponent {} | ||
|
||
// Prettier stable | ||
@Component({ | ||
template: `<div>...</div>`, | ||
styles: `h1 { color: blue; }`, | ||
}) | ||
export class AppComponent {} | ||
|
||
// Prettier main | ||
@Component({ | ||
template: `<div>...</div>`, | ||
styles: ` | ||
h1 { | ||
color: blue; | ||
} | ||
`, | ||
}) | ||
export class AppComponent {} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/format/typescript/angular-component-examples/15934-computed.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
const styles = "foobar"; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
template: ` | ||
<h1>My App</h1> | ||
<app-todo-list></app-todo-list> | ||
`, | ||
[styles]: `h1 { color: blue }` | ||
}) | ||
export class AppComponent {} |
11 changes: 11 additions & 0 deletions
11
tests/format/typescript/angular-component-examples/15934.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
template: ` | ||
<h1>My App</h1> | ||
<app-todo-list></app-todo-list> | ||
`, | ||
styles: `h1 { color: blue }` | ||
}) | ||
export class AppComponent {} |
156 changes: 156 additions & 0 deletions
156
tests/format/typescript/angular-component-examples/__snapshots__/jsfmt.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters