clojurescripthoplon

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.


Solution

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