Fork me on GitHub
#reagent
<
2023-03-31
>
Ryan00:03:05

Not sure if its exactly reagent specific, but how do I output html I am receiving from a db as a string.. so far all my attempts have dutifully escaped it, but in this case I don’t want it escaped (its not user input so not worried about sanitizing it)

Ryan01:03:32

In case anyone else runs into this problem: [:div {:dangerouslySetInnerHTML {:_html VAR-WITH-HTML_}}]

Jakub Šťastný13:03:19

Hey guys. I have this:

[breadcrumbs
  [:a {:href "/"} "Home"]
  [:a {:href "/dashboard"} "Dashboard"]
How do I make it work programatically (having a fn returning list of these breadcrumbs)? The minute I introduce :<>, the individual breadcrumbs are no longer direct children of breadcrumbs, so they render without the formatting this component provides. Essentially I want something like:
[breadcrumbs (build-breadcrumbs current-route)]
But no matter what I try, it's just not producing the desired structure with :a being a direct children of breadcrumbs. (Essentially I want an analog to ~@ in macro expansion.) Is there a way to do it in hiccup?

Jakub Šťastný13:03:01

Probably completely irrelevant, but breadcrumbs comes from https://mui.com/joy-ui/api/breadcrumbs/

p-himik13:03:28

(into [breadcrumbs] ...)

👍 2
p-himik13:03:08

Or a for loop as the only child, but only if you can provide a unique ^{:key ...} for each anchor vector.

Jakub Šťastný13:03:57

I found another way FYI:

[breadcrumbs {:children [
  (r/as-element [:a {} "Test"])
  (r/as-element [:a {} "abc"])
  (r/as-element [:a {} "xyz"])]}]