HTML tag closes when inside a condition

I'm having a little problem with jade. Here is the following code :

            each user in users
                - if (user.valid == 1)
                    tr(style="color:green;")
                - else
                    tr(style="color:red;")

                        td
                            = user.mail
                        td
                            = user.lastIp
                        td
                            = user.token
                        td
                            = user.valid

My problem is that the tds are created only in the else case. if the if (user.valid == 1) is true, then it creates an empty tr.

Is there a way I can create my tr with this condition, and then only fill them ?

Thanks :)

Your code translated to:

-if (user.valid == 1)
    <tr style="color:green;" />
-else
    <tr style="color:red;" >
        td
            = user.mail
        td
            = user.lastIp
        td
            = user.token
        td
            = user.valid
    </tr>

You should replace it with:

-if (user.valid == 1) {
    tr(style="color:green;")
-} else {
    tr(style="color:red;")
-}

        td
            = user.mail
        td
            = user.lastIp
        td
            = user.token
        td
             = user.valid

Good luck! Shai

Not sure if it is the best way to do it but I created a variable to store my color, here is my solution :

                - if (user.valid == 1) {
                    - color = "green";
                - } 
                - else {
                    - color = "red";
                - }

                    tr(style="color:#{color};")