scittle 2023-05-18

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?

Not sure what you mean exactly

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

I didn't understand the "from HTML" part

how do you "pass from HTML"?

🤷🏼‍♂️ 1

I was guessing he meant http fetch

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…

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?

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

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