Auto format Angular html templates
npm install @shinnqy/angular-template-formatterhtml
Hero Search
(click)="gotoDetail(hero)" class="search-result" >
{{hero.name}}
will get formatted to:
`html
Hero Search
#searchBox
id="search-box"
(keyup)="search(searchBox.value)"
>
*ngFor="let hero of heroes | async"
(click)="gotoDetail(hero)"
class="search-result"
>
{{hero.name}}
Recommended Configuration:
`
{
// turn off default vs code formatter
"html.format.enable": false,
// enable formatting by default
"editor.formatOnSave": true,
"editor.formatOnPaste": true
}
`
Release Notes
$3
Preserves HTML escaped entitities
$3
Does not remove tags when formatting.
$3
Now formats svgs in templates
$3
Added option for preventing closing tag > from being on their own line: angular-template-formatter.closeTagSameLine`. Thanks @larscom!