Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the new Angular @let syntax #2319

Open
Tortila90 opened this issue Oct 3, 2024 · 3 comments
Open

Support for the new Angular @let syntax #2319

Tortila90 opened this issue Oct 3, 2024 · 3 comments

Comments

@Tortila90
Copy link

Description

Angular 18.1 introduced the new @let syntax: https://angular.dev/api/core/@let

It differs from the recently added @if or @for, because it doesn't contain any following brackets or parentheses.

As of now any code in a file that comes after @let may not be formatted correctly, especially if there are more @if or @for.

Input

With this new feature, when I give like this input:

@let foo = 'bar';
<div>
  @if (foo) {
  {{ foo }}
}
</div>

Expected Output

I'd like to see this output:

@let foo = 'bar';
<div>
  @if (foo) {
    {{ foo }}
  }
</div>
@liesahead
Copy link

This is so much needed, if I correctly remember the approximate implementation it should not be difficult to extend keywords list.

@ozearkhan
Copy link
Contributor

@bitwiseman is this issue still available to take on? any guidance on specific areas I should focus on would be appreciated.

@Tortila90
Copy link
Author

@bitwiseman is this issue still available to take on? any guidance on specific areas I should focus on would be appreciated.

@ozearkhan There is a comprehensive definition of this syntax in the docs. I hope this will help.

The @let syntax is formally defined as:

  • The @let keyword.
  • Followed by one or more whitespaces, not including new lines.
  • Followed by a valid JavaScript name and zero or more whitespaces.
  • Followed by the = symbol and zero or more whitespaces.
  • Followed by an Angular expression which can be multi-line.
  • Terminated by the ; symbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants