how to emulate a “one branch if” to add attributes to an Html element when a certain condition is met ?
In imperative languages you can do: say
if condition(): list_attributes.append(class="my_class") do_some_other_stuff()
The same problem happens with adding, or not adding Html children nodes to a parent element. What I do in this situation is I use a:
in the branch when the condition isn’t met.
But there’s no “empty attribute” I can use for attributes (unless I missed that in Elm Attribute library).
What I do is use list concatenation with empty lists when the condition isn’t met, but that makes the code quite heavy and unreadable, and long to type.
Is there a better way?