I’m trying to figure out how to create attributes that start with certain special characters:
• a colon like one might for https://alpinejs.dev/directives/bind#shorthand-syntax (`<div :class="open ? '' : 'hidden'"> … </div>`). [:div {::class "…"}] wouldnt work, because the double-colon does auto-resolution
• an @ (similarly also because of alpine.js): (`[:div {:@mouseenter="hello"} ...]` does not work, and the attribute gets dropped)
How do I generate these attributes with rum?
If it works, it’s valid :)
sure. I'm just hoping this "fix" does not go away!
from my quick reading of https://github.com/tonsky/rum/blob/1e1fb15c65b80c4962288fbbbab0610e0daa3250/src/rum/server_render.clj#L318, it would appear that this fix should be fine.
If render-attr! is what is used to render an attribute, the actual "attribute" that gets generated is something passed through https://github.com/tonsky/rum/blob/1e1fb15c65b80c4962288fbbbab0610e0daa3250/src/rum/server_render.clj#L189-L193, which ends up calling name on it. So if you use a string as the attribute name already, it's preserved.
oh hey @tonsky, I just realized you're http://github.com/tonsky... Thank you for replying; I will take this as the string form being valid then. Note though that I have filed https://github.com/tonsky/rum/issues/265; even if specifying an attribute as a string is ok, it should at least be noted in the README as well.
hm, on a hunch, I decided to just use a string instead of a keyword for the attribute name, and that seems to work. I don't see it in the README though, so... is this a valid fix?
[:div {":class" "open ? '' : 'hidden'" "@mouseenter" "hello"} ...]