Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one add a conditional inside of a link in jade?

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
like image 596
k00k Avatar asked Feb 28 '12 19:02

k00k


1 Answers

How about

a(href="/foo", class=(current_route[1] === 'foo')? "active" : "") Go to Foo

like image 147
Sơn Trần-Nguyễn Avatar answered Nov 01 '22 23:11

Sơn Trần-Nguyễn