pug Conditionals If/Else Statement in Pug (with a dash)


You can choose to prepend an if or else operator with a dash, but it is not necessary. You will need to wrap the statement in parentheses, though (if you omit a dash, you do not need parentheses.)

- var showLogin = false;
- if (showLogin === true)
    .welcome Welcome back to our website!
- else
        a(href="/login") Login

index.pug output

<div class="login"><a href="/login">Login</a></div>