scittle

chromalchemy 2023-05-18T12:38:46.787949Z

What is the most efficient way to pass data from html to scittle cljs? I could read some json from a string. Can I pass EDN data as a string?

borkdude 2023-05-18T12:39:56.290509Z

Not sure what you mean exactly

ray 2023-05-18T13:09:06.179159Z

If you pass EDN you can read it directly rather than going via JSON

borkdude 2023-05-18T13:12:22.202559Z

I didn't understand the "from HTML" part

borkdude 2023-05-18T13:12:31.164039Z

how do you "pass from HTML"?

🤷🏼‍♂️ 1
ray 2023-05-18T20:53:44.602669Z

I was guessing he meant http fetch

chromalchemy 2023-05-23T19:01:39.698959Z

Thanks for the feedback. read-string sounds most appropriate for this case. I will try that. I’ll make a simplified repo later for public consideration…

chromalchemy 2023-05-22T18:03:41.903409Z

Sorry for late response.. On my stack I have a Handlebars.js HTML templating language with some data-store access patterns built into syntax. I can access the data in the Handlebars code and render it in HTML in the same .html template file. What if I want to use that (indirectly sourced) data in Scittle? Currently I am rendering a string in a html data attribute, then in Scittle cljs, accessing that dom node, reading the data value, and parsing the string into a cljs data structure… Is there a more direct way? If I “print” an EDN literal into this html, can Scittle cljs “read” that as cljs data directly somehow? I think technically it would still be a string coming into cljs runtime. Is there a read-edn fn? I could render an additional Scittle <script> tag in the html, with a def’d EDN value, and Scittle could likely just see that as named data. But then the placing of the script tag might be complicated…? I would probably be better off trying to get the json data more directly (from fetch or something), but I was curious what was supported?

borkdude 2023-05-22T18:04:32.526119Z

> is there a read-edn fn? yes, this function is in clojure.edn/read-string?

borkdude 2023-05-22T18:05:49.318269Z

perhaps if you have github project + index.html page I could look at locally, I could say more