hzhu
hzhu

Reputation: 3799

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"]

Upvotes: 6

Views: 552

Answers (1)

edbond
edbond

Reputation: 3951

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"]

Upvotes: 4

Related Questions