Skip to content

Commit

Permalink
Switch htmlWhitespaceSensitivity to 'ignore'
Browse files Browse the repository at this point in the history
  • Loading branch information
joematthews committed Jan 29, 2024
1 parent 85dbc25 commit b5fec7b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"htmlWhitespaceSensitivity": "css",
"htmlWhitespaceSensitivity": "ignore",
"plugins": [
"prettier-plugin-sh",
"prettier-plugin-css-order",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Adds the following compiler options to the [tsconfig.json file](./tsconfig.json)

Uses [Prettier](https://prettier.io/) to provide opinionated formatting so diffs contain less formatting changes and teams argue less about formatting in general.

In the [.prettierrc.json file](./.prettierrc.json), `htmlWhitespaceSensitivity` has been set to `css` to improve the formatting of templates. This will trim whitespace immediately before and after inline elements. (If disabled, this setting will be difficult to reenable in the future.)
In the [.prettierrc.json file](./.prettierrc.json), `htmlWhitespaceSensitivity` has been set to `ignore` to improve the formatting of templates. This will trim whitespace around and inside elements. Use ` ` (non-breaking space) to explicitly enforce spacing between inline elements. (If disabled, this setting will be difficult to reenable in the future.)

The following prettier plugins are used:

Expand Down
20 changes: 19 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import { UpperCasePipe } from '@angular/common';
import { Component } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { RouterOutlet } from '@angular/router';

@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, MatButtonModule],
imports: [RouterOutlet, MatButtonModule, UpperCasePipe],
template: `
<h1 i18n>Hello, {{ title }}!</h1>
<p i18n>
The theme colors are:&nbsp;
@for (color of colors; track color; let index = $index) {
<button
mat-raised-button
type="button"
[color]="color === 'none' ? '' : color"
>
{{ color | uppercase }} {{ index }}
</button>
@if (index < colors.length - 1) {
&nbsp;
}
}
</p>
<router-outlet />
`,
styles: ``,
})
export class AppComponent {
title = 'opinionated-angular';

colors = ['none', 'primary', 'accent', 'warn'];
}

0 comments on commit b5fec7b

Please sign in to comment.