Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在玉中使用 if -else 关于“包含”的语句?
例如,如果我有两个单独的导航栏模板 navbar.jade 和 navbar_notloggedin.jade
我想要做:
input(type='hidden', value= user.user)#username - if(user.user!="") include navbar - else if(user.user=="") include navbar_notloggedin
您可以使用,
-if (user.user) include navbar -else include navbar_notloggedin
if 语句将检查变量是否已定义,而不是检查它是否为空字符串。但是,我假设您没有为用户存储空字符串值。