简体   繁体   中英

How to Switch Tags in Hoplon

If I have the following code and a function to switch from 'p' tag to 'h1' tag:

 (def switch-tag (cell p))

And later on in the hlisp

 ((cell= switch-tag) "Text goes here")

How come when I switch to the h1 tag nothing seems to happen.

I have been unable to solve this your way. Here is a workaround:

(page "index.html")

(def key! (cell true))

(defelem my-elem [_ [child]]
         (cell= (if key! (h1 child) (p child))))

(html
    (body
        (button :click #(swap! key! not) "test")
        (my-elem "this is a test")))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM