Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I parse string into Hiccup?

How can I parse a string of Hiccup into a Hiccup node?

For example, "[:b 'hello world']" into [:b "hello world"]

like image 666
Henry Zhu Avatar asked Oct 20 '22 15:10

Henry Zhu


1 Answers

Use reader to convert string to data structures:

user=> (clojure.edn/read-string "[:b 'hello world']")
[:b 'hello world']

You should use " to denote string:

user=> (clojure.edn/read-string "[:b \"hello world\"]")
[:b "hello world"]
like image 151
edbond Avatar answered Oct 22 '22 23:10

edbond