Jade/Pug if else condition usage

前端 未结 3 1491
天命终不由人
天命终不由人 2021-02-05 09:05

I\'m sending a date to a .jade file from my .js file using Node.js. When the #{date} field is false, it executes the else and print

3条回答
  •  抹茶落季
    2021-02-05 09:57

    If date is false, do you want to output the string 'man'? If yes, your if and else statements are the wrong way around...

    How about:

    if date
      = date
    else
      | man
    

    or even:

    | #{date ? date : 'man'}
    

    or simply:

    | #{date || 'man'}
    

提交回复
热议问题