问题
How does one add a conditional inside of a tag (link/anchor in my case) in jade?
Here's my pseudo code that of course won't work:
a(href="/foo", class="if (current_route[1] == 'foo'){active}") Go to Foo
回答1:
How about
a(href="/foo", class=(current_route[1] === 'foo')? "active" : "") Go to Foo
来源:https://stackoverflow.com/questions/9488029/how-does-one-add-a-conditional-inside-of-a-link-in-jade