I have a line of HAML like this:
%li{:id=>node.shortcode, :class=>liclass unless liclass.empty? }
which doesn’t work. I only want to pass the ‘class’ parameter if the condition provided isn’t true. Is there a nice way to do this in Ruby will I just have to use an if/else?
Try this:
It’s not pretty, but it gives you the markup you’re after.