angularpug

How can you implement new @for @if syntax introduced in Angular 17 in PUG?


I have been using PUG in my Angular application and I like the new syntax introduced in Angular 17 regarding @for and @if, replacing *ngFor and *ngIf. I wasn't sure how to implement this via PUG.

When I try to implement it via pug by typing in @for, I get an error:

unexpected text "@for("

Maybe I need to wait for a newer version of pug?


Solution

  • I found a solution in the issues for ngx-pug-builders

    The short answer is that you put a '|' at the start of the so-called control flow lines. Note that you do not indent the first line of the control flow block:

    |@if(a>b) {
    div() 
    |}