Regarding if statements in lighterHTML

83 views Asked by At

I am curious as to how to do if-statements in LighterHTML. I need to show a certain button only when a certain statement is true. This if-statements need to be done in the rendering HTML part.

<button onclick=${() => this.deleteAll()} class="btn btn-primary">Verwijder alle</button>

Could anyone help?

1

There are 1 answers

1
Alex Shesterov On

You can use a ternary operator:

html`
    ${myCondition
        ? html`<button onclick=${() => this.deleteAll()} class="btn btn-primary">Verwijder alle</button>`
        : html``
    }    
`;