I’m trying to render some Ornament hiccup in Portal . It has a notion of styled components that the default hiccuo viewer only seems to want to view as data (not rendering or displaying the html) Ornament works with lamdaisland hiccup. So I could pre-render the html. But i also cant figure out how to render any html string. The portal.viewer/html metadata doesnt seem to do it. (Can you even set metadata on a string?) https://github.com/lambdaisland/ornament
Seems like sometimes I get a stale view that wont update until I clear. Even with same metadata. But will look to replicate. But it’s a minor issue. It’s great to be able to drive the view from code, so I can integrate the coding flow with Calva repl snippets!
No, strings don't support metadata. However, you can use https://github.com/djblue/portal/blob/master/src/portal/viewer.cljc#L162-L164 which will wrap the string in something that does support metadata 👌
This is not working for me. Just shows the regular inspector.
(->
"hello world"
(portal.viewer/html)
(with-meta
{:portal.viewer/default :portal.viewer/html})
(tap>))
Any hints?You just want to do:
(-> "<div>hello world</div>"
(portal.viewer/html)
(tap>))Ok that works! 🥳
But I had tried it before…?
I had to p/clear before I could see the properly rendered output.
If I am testing different values in the tap> pipeline, the portal view seems to remember earlier values and not update (or just keeps showing the old data), and it seems like things aren’t working.
If I explicity clear, then I get the fresh proper render.
Is this the case that explicit clearing is generally required?
In this case I had started up a portal view with this, so I thought I was good on the clearing.
;; start portal: only show one result,
(comment
(do
(def last-tap (atom nil))
(defn clear-submit [value]
(reset! last-tap value))
(p/inspect last-tap {:launcher :vs-code})
(add-tap (var clear-submit)))
)What would you call this caching behavior so I can learn more about it?
(I probably need to learn more about tap>
Previous experience https://clojurians.slack.com/archives/C0185BFLLSE/p1708203004322939?thread_ts=1708119965.934519&cid=C0185BFLLSE
Since metadata isn't part of equality, if the only thing changing is metadata, nothing will re-render.