How can one use if -else statement on "include" in jade??
For example, if I have two separate navigation bar templates navbar.jade and navbar_notloggedin.jade
I would like to do:
input(type='hidden', value= user.user)#username
- if(user.user!="")
include navbar
- else if(user.user=="")
include navbar_notloggedin
You can use,
-if (user.user)
include navbar
-else
include navbar_notloggedin
The if statement will check whether the variable is defined or not, not whether it is an empty string or not. However, I assume you are not storing empty string values for user.