Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quotes in strings #57

Open
larstvei opened this issue Jul 7, 2024 · 0 comments
Open

Quotes in strings #57

larstvei opened this issue Jul 7, 2024 · 0 comments

Comments

@larstvei
Copy link

larstvei commented Jul 7, 2024

Hi!

Using pr-str, you can print arbitrary edn data, and read it on the client side using read-string, i.e.

user> (read-string (pr-str {:a "a"}))
{:a "a"}

Passing something like this to hiccup.core/html gives the following:

user> (println (hiccup.core/html [:div {:data-example (pr-str {:a "a"})}]))
<div data-example="{:a &quot;a&quot;}"></div>

When getting the data-example field from ClojureScript, I can read-string the resulting string and get the data structure back.

Passing the same to dumdom.string/render gives this:

user> (println (dumdom.string/render [:div {:data-example (pr-str {:a "a"})}]))
<div data-example="{:a "a"}"></div>

Here, the data-example does not contain the expected string.

Note this is not a big issue, as something like:

user> (println (dumdom.string/render [:div {:data-example (clojure.string/escape (pr-str {:a "a"}) {\" "&quot;"})}]))
<div data-example="{:a &quot;a&quot;}"></div>

gives the expected result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant