Joined December 2015
·

LuanPham

Ho Chi Minh city, Vietnam
·
·

@zinkkrysty
I was thinking the same as you before, but when you need several conditional attributes, it will get messy, like this:

%tr{ class: ("active" if row.name == "active"), title: ("active" if row.name == "active"), data-id = #{row.id} }

instead you can write it like this

%tr{ {data-id = #{row.id}}, row.name == "active" ? { class: "active", title: "active" } : { } }

unconditional attributes can be placed into different hash, and the two hashes will be flatten by haml, I think. And sorry that I don't know how to beautify my code in a block :D

Achievements
1 Karma
0 Total ProTip Views