portal

chromalchemy 2024-02-29T17:54:28.668609Z

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

chromalchemy 2024-03-04T17:10:32.464969Z

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!

djblue 2024-02-29T20:45:22.782629Z

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 👌

chromalchemy 2024-02-29T21:41:44.872059Z

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?

djblue 2024-02-29T21:56:24.303989Z

You just want to do:

(-> "<div>hello world</div>"
    (portal.viewer/html)
    (tap>))

chromalchemy 2024-02-29T23:09:45.930189Z

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?

chromalchemy 2024-02-29T23:10:32.658569Z

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)))
  )

chromalchemy 2024-02-29T23:10:58.327829Z

What would you call this caching behavior so I can learn more about it? (I probably need to learn more about tap>

djblue 2024-03-01T20:31:36.943849Z

Since metadata isn't part of equality, if the only thing changing is metadata, nothing will re-render.

👍 1