Closed egri-nagy closed 9 months ago
Thanks, @egri-nagy.
In the version I pushed today, it is possible to handle a single form without providing the context of a source file:
;; in the context of the current namespace (`*ns*`)
;; as HTML
;; and show it at the browser.
(clay/make! {:format [:html]
:single-form '(kind/cytoscape
[{:style {:width "300px"
:height "300px"}}
cytoscape-example])})
I see that your need is slightly different -- handling a value rather than a pre-evaluated form. I removed that option from the API since I had no idea it had been in use.
If this seems important, I can add an option for that.
Version 2-alpha47
or later should support the code snippet above.
Hi @daslu,
Thank you for your work! I think this would cover my use-case, but now there seems to be some problem:
serving Clay at http://localhost:1971/
Exception in thread "main" java.io.FileNotFoundException: /.clay.html (Read-only file system)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:289)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:230)
at clojure.java.io$fn__11619.invokeStatic(io.clj:230)
at clojure.java.io$fn__11619.invoke(io.clj:230)
at clojure.java.io$fn__11543$G__11525__11550.invoke(io.clj:69)
at clojure.java.io$fn__11631.invokeStatic(io.clj:263)
at clojure.java.io$fn__11631.invoke(io.clj:259)
at clojure.java.io$fn__11543$G__11525__11550.invoke(io.clj:69)
at clojure.java.io$fn__11593.invokeStatic(io.clj:166)
at clojure.java.io$fn__11593.invoke(io.clj:166)
at clojure.java.io$fn__11556$G__11521__11563.invoke(io.clj:69)
at clojure.java.io$writer.invokeStatic(io.clj:119)
at clojure.java.io$writer.doInvoke(io.clj:104)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$spit.invokeStatic(core.clj:7021)
at clojure.core$spit.doInvoke(core.clj:7021)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at scicloj.clay.v2.server$update_page_BANG_.invokeStatic(server.clj:203)
at scicloj.clay.v2.server$update_page_BANG_.invoke(server.clj:191)
at scicloj.clay.v2.api$start_BANG_.invokeStatic(api.clj:17)
at scicloj.clay.v2.api$start_BANG_.invoke(api.clj:15)
Is it a problem with the temporary file creation? Or am I missing some configuration?
This happens both from REPL, or when using a jar file.
Thanks, @egri-nagy!
The problem above (which seems to be the same as #27) is fixed in version 2-alpha49
.
Handling a value, not just a form, is now supported.
So, both (make! {:single-form '(+ 1 2)})
and (make! {:single-value 3})
should work.
This is a bit simpler than the code snippet above because :format [:html]
is now the default and does not need to be mentioned explicitly.
Yes, I can confirm that 2-alpha49
works fine. Thanks a lot!
Thanks!
Around alpha38 I used
handle-value!
to display graphs generated on the fly to display them in the browser, likeAs of alpha42, it seems the assumption is that a notebook already is in a file - examples all seem to specify source-path.
Is there still a way to render a value (just a vega-lite diagram, or a table, or a hiccup document) without storing it in a file first?