example composing expressions impl#18
Conversation
|
This is brilliant, thanks tom! With regards to names: we can sort that out. It seems to me that As for the use of walk, your example code in the linked issue didn't use walk, but I guess it only processed the top level forms. Hm will have to noodle on this. It might be ok to eat the cost and provide an escape hatch to the current |
|
Just added a commit which removes the runtime walk. The basic changes are:
I'm sure you noticed squint doesn't give us an api that takes data, just a string api, so in this impl I'm just making use of the traversal that already has to happen when serializing the forms we pass to squint. |
|
I'm on vacation, so I won't be able to get back to this until next week. But I think its great! Excited to try it myself. |
|
Update: I've reviewed this and quite like it. I intend to merge it as soon as I can address the build failure. |
I'm just opening this to further the discussion in #15. I don't think this is production-ready code.
With this impl, datastar expressions compose more easily. The two new public API macros I added are
d*jsandd*js-str.d*jsis like->exprbut it returns a JSExpression object. Note that Chassis automatically callsstron these objects, so if using Chassis we can use code like:That's just like what we'd do with
->expr. For usage in contexts that don't automatically coerce to string, you could expose thed*js-strmacro, which is just(str (d*js ~@forms)). Or callers could just callstrdirectly.The important change vs the current implementation of this lib is that expressions compose easily:
The main problems I have with this impl are: