如何在Clojurescript(OM / Reagent)中使用Hickory?

时间:2015-01-04 07:07:59

标签: clojure reactjs clojurescript hiccup om

在我的Reagent项目中,我正在使用Hickory解析HTML并呈现一个Hiccup页面。打嗝出现了。但是当我更改页面(!reset my view atom )时,React.js变得疯狂,因为Hickory已经生成:

[:div (as-hiccup (parse "<h1>HELLO WORLD!</h1>"))]

=> ([:html {} [:head {}] [:body {} [:h1 {} HELLO WORLD!]]])

正如您所看到的,它已生成<html> <head> <body>个标记,我认为这会导致Reactjs爆炸,因为我的视图已经有了这些标记。理想情况下,我希望它只生成[:h1 {} HELLO WORLD!]

1 个答案:

答案 0 :(得分:1)

(map as-hiccup (parse-fragment "<h1>HELLO WORLD!</h1>"))

生成[:h1 "HELLO WORLD!"]