Fork me on GitHub
#portal
<
2024-02-29
>
chromalchemy17:02:28

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

djblue20:02:22

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 👌

chromalchemy21:02:44

This is not working for me. Just show the regular inspector.

(->
  "<div>hello world</div>"
  (portal.viewer/html)
  (with-meta 
    {:portal.viewer/default :portal.viewer/html})
  (tap>))
Any hints?

chromalchemy23:02:45

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?

chromalchemy23:02:58

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

djblue20:03:36

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

👍 1
chromalchemy17:03:32

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!