r0man / sablono

Lisp/Hiccup style templating for Facebook's React in ClojureScript.
Eclipse Public License 1.0
696 stars 66 forks source link

Add support for more forms (e.g. `when`) #184

Closed zlorf closed 6 years ago

zlorf commented 6 years ago

The compiler "walks" properly on some forms, but not on others:

user=> (compile-html '(if 6 [:div.x.y {:href 6} "text"]))
(if 6 (js/React.createElement "div" #object[cljs.tagged_literals.JSValue 0x631a57c2 "cljs.tagged_literals.JSValue@631a57c2"] "text"))
user=> (compile-html '(when 6 [:div.x.y {:href 6} "text"]))
(sablono.interpreter/interpret (when 6 [:div.x.y {:href 6} "text"]))

I think that some popular forms are missing here. @rauhs has included a more comprehensive list: https://github.com/rauhs/hicada/blob/master/src/hicada/compiler.clj#L159

Maybe we can move those multimethods, with the proper author attribution?

r0man commented 6 years ago

@zlorf Sure, PR with some tests welcome!

rauhs commented 6 years ago

No attribution required. I think some of them also came from others from a gist.

zlorf commented 6 years ago

@r0man I'll prepare PR and tests. But I've just found that test-element-meta is broken (no expected in the are macro, and even after adding it the test fails). I'm invoking the tests via lein ci.

r0man commented 6 years ago

@zlorf Yes, you are right. I fix it over here: https://github.com/r0man/sablono/pull/185

zlorf commented 6 years ago

Excellent, thanks!

r0man commented 6 years ago

@zlorf I added a couple of more forms from @rauhs (thanks!) hicada's allgäu ;)

zlorf commented 6 years ago

@r0man Thanks! I was considering to try refactor my approach to invoke clojurescript macro compiler (no time, though). But, well, enumerating all forms is still a solution. :)