Lolo
Lolo

Reputation: 537

Jade : Short version of if then

I have this code which works

if (activePage === 'index')
    a.active(href="index.html") Index
else
    a(href="index.html") Index

I'd like to short it with something like :

- var vclass = #{activePage==='popol' ? 'active' : ''};
a(class=#{vclass}) Index

or better something like

a(class=#{activePage==='index' ? 'active' : ''}) Index

Upvotes: 0

Views: 52

Answers (1)

Ha Huu Tin
Ha Huu Tin

Reputation: 334

I think this code should work and is better

a(href='index.html' class=activePage === 'index' ? 'active' : '') Index

Upvotes: 2

Related Questions