Pug can conditionally run code based on variables (passed from your server or based in Pug itself).
if (statement)
// Pug code
else if (statement)
// Pug code
else
// Pug code
unless (statement)
// Pug code
Parameter | Details |
---|---|
if (statement) | Evaluates statement to see if it returns true or false. The code nested underneath if will run only if statement returns true. |
else if (statement) | Chained to an existing if or else if statement; it only runs if the previous statement evaluated to false. The code nested underneath the else if statement will run only if statement evaluates to true. |
else | The code nested underneath the else statement will run only if all previous statements returned false. |
unless (statement) | The negation of if (statement) ; the code nested underneath if will run only if statement returns false. It is the same as if (!statement) . |