-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Open
Copy link
Labels
lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)Issues affecting Angular template (not general JS/TS issues used for Angular)
Description
Prettier 1.15.3
Playground link
--parser angularInput:
<div title="{{ $ctrl.collapsed ? 'Expand' : 'Collapse' | resource }}"></div>
<div [title]="$ctrl.collapsed ? 'Expand' : 'Collapse' | resource"></div>Output:
<div title="{{ $ctrl.collapsed ? 'Expand' : ('Collapse' | resource) }}"></div>
<div [title]="$ctrl.collapsed ? 'Expand' : ('Collapse' | resource)"></div>Expected behavior:
Same as input.
UPD
Turns out it is a grammar difference between AngularJS and Angular.
In AngularJS, a ? b : c | x means (a ? b : c) | x.
In Angular, a ? b : c | x means a ? b : (c | x).
It would make sense if Prettier kept such expressions as is to stay compatible with both. Now, it corrupts AngularJS templates.
robertcoopercode and icopp
Metadata
Metadata
Assignees
Labels
lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)Issues affecting Angular template (not general JS/TS issues used for Angular)