Anybody know if there is a quick way to represent HTML comments in reagent hiccup?
The only way is probably via dangerouslySetInnerHTML, which also requires knowing the parent element.
ok, thanks for the quick reply!
Seems like you could also create a custom component for that: https://stackoverflow.com/a/41131326/564509 A little bit more involved than just using Hiccup.
@p-himik Yeah, I also found that same resource after googling it. Think I’m gonna attempt something like that 😉
Just out of interest - why do you need HTML comments at all?
@p-himik I need to embed XML inside an HTML page as HTML custom elements and want to be as faithful to the source as possible. It’s not really necessary, I guess, but why not? Kind of a fun exercise ;)
I see. Is the original form of the XML string or Hiccup?
it’s an XML string that I’m parsing with the DOM api and then converting to hiccup. I have a bunch of linguists manually transcribing old letters from the 1930s into this XML format and I’m tasked with creating a reader for it in the browser.
So you have a "string->DOM api->hiccup->React elements" conversion.
You can probably use dangerouslySetInnerHTML on the parent where you embed the XML and avoid any conversion at all.
That is, unless you also transform/process the XML data in Clojure[Script].
be careful using dangerouslySetInnerHTML with non-static things. a compromise in your db or other area of your site could lead to XSS exploits
@vijay_edwin has joined the channel