How to Switch Tags in Hoplon

43 views Asked by At

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.

1

There are 1 answers

0
akond On BEST ANSWER

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