Hi,
I want to set an attribute dynamically. This was my naive implementation:
(html/defsnippet role-option (str globals/template-path "admin.html") [(html/attr= :field "role_option")]
[option selected]
[(html/attr= :field "role_option")] (html/do->
(html/content (name option))
(when selected (html/set-attr :selected selected))))
This has the problem that "when" returns nil if it does not hit the condition and then do-> will try to do something with "nil" which does not work and lead to a NPE.
What is the enlive way to achieve this? Are there any code examples? I have not found anything that makes sense to me.
Best Regards,
Sven