Don’t use instance variables in partials. Pass local variables to partials from view templates.
I’d like to clarify if this implies that local variable definitions are OK in haml. Or if they should be avoid. I’ve also been trying to using page objects can avoid conditionals in the haml, but those also seem impossible to totally avoid.
I’ve got this haml code which needs to do something with the first value from the association. Should this be done any differently?
.row .col-sm-12 - first = obj.my_children.first .class-for-first = first.some_value - first = true .class-for-rest %ul - obj.my_children.each do |child| - if first - first = false -else %li = child.some_value