question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular formatter line breaks in double-curly braces cause whitespaces

See original GitHub issue

Prettier 1.15.2 Playground link

# Options (if any):
# none

Input:

<h2 class="modal-title">{{ error == null || error.title == null ? 'someLongString' : someOtherInterestingValue }}</h2>

Output:

<h2 class="modal-title">
  {{
    error == null || error.title == null
      ? "someLongString"
      : someOtherInterestingValue
  }}
</h2>

This adds a leading and a trailing whitespace within h2. This is a problem when checking the textContent of h2 within a unit test.

Expected behavior:

<h2 class="modal-title">
  {{ error == null || error.title == null
      ? "someLongString"
      : someOtherInterestingValue }}
</h2>

Adding <!-- display: block --> before the h2 tag does not change anything.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
thorn0commented, Nov 13, 2018

Your expected behavior would still create extra text nodes. Didn’t you mean something like this:

<h2 class="modal-title">{{
  error == null || error.title == null
    ? "someLongString"
    : someOtherInterestingValue
}}</h2>

?

2reactions
theoptzcommented, Jul 23, 2019

the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove spaces from double curly brackets in Angular ...
It seems Angular Docs itself is a bit inconsistent in using spaces around curly brackets, but I would like to normalize this for...
Read more >
Expressions | Handlebars
Handlebars expressions are some contents enclosed by double curly braces {{}} . In the below template, firstname is a variable that is ...
Read more >
CSS Basics: The Syntax That Matters & The Syntax That Doesn't
All CSS rulesets must have opening and closing curly braces: ... A line break is treated like any other white space in CSS,...
Read more >
The Best Angular Examples - freeCodeCamp
Inside the double curly braces, a variable's value is mapped from the ... by any whitespace character, such as a space, tab, or...
Read more >
angular 2 escape html
Angular Escape Html Curly Braces How to use double curly braces in the angular ... The sanitizer will leave safe HTML intact and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found