I posted https://clojurians.slack.com/archives/C08H80CUR/p1727774744340599?thread_ts=1672392856.470579&cid=C08H80CUR to #rum, but I'm thinking perhaps some folks here might have faced this question. How do you stop rum from escaping the value of an attibute. Not the inner html, mind you, but the value of an attribute? My use case would be because I am using alpinejs, and need actual quotes to be in the value of https://alpinejs.dev/magics/data.
just took a look at the rum source and have confirmed rum doesn't have any options to disable attribute escaping. See this function in particular: https://github.com/tonsky/rum/blob/005a2f067178808f92dc796f2c867cc152793279/src/rum/server_render.clj#L315
so the options would be:
• fork rum
• switch to something else (like https://github.com/lambdaisland/hiccup -- I don't know if that escapes attribute values though)
• render bits of the html before-hand via dangerouslySetInnerHtml
• render a placeholder and then do a string replace (e.g. [:div {:foo "$BAR"}] -> (str/replace rendered-html "$BAR" "..."))
if lambdaisland/hiccup or another library works, that's probably the route I would go. If there aren't any hiccup-based libraries that support un-escaped attributes... then seems like forking might not be a bad option actually! Maybe could get a PR accepted into rum.
let me know what solution you end up on--I wouldn't be opposed to switching out Biff's rum dependency for something else
thank you Jacob for the comprehensive reply! I did have a look at hiccup (especially after seeing how it doesnt look like there is any way currently to not escape the attribute value with rum), but I’m not sure that hiccup has it (and it would also need to have a resolution for the https://github.com/tonsky/rum/issues/created_by/jf that I currently have right now; more on that later). My preference right now would be to stick with rum. It seems to be a good choice, outside of my issues. On the 2 issues, only one of them is a real problem, which is this one I’m asking for help for. https://github.com/tonsky/rum/issues/265 would be perhaps a documentation issue. If I were to stick with rum though, I think the way forward would be to provide a PR if I can. Forking’s possible, but I have no idea right now about how to make things available on clojars. But as it is, if I could provide a fix in a fork, I might as well provide the PR.