sablono
sablono copied to clipboard
Custom Tags
I know it explicitly says NOT to do this in the README... BUT, let me make the pitch.
I've written a bunch of components in Om-Bootstrap that could easily be hooked into Sablono's renderer, if I were able to extend specific (namespaced) keywords in the markup to call out to my om-bootstrap components.
For example,
[:div
[::b/button {:bs-style "primary"}
[:a "Anchor tag"]]]
::b/button
would pass the options and children into om-bootstrap.button/button
.
What do you think? Is this a feature you guys would be interested in?
Hi Sam, could you provide more details on how this should work? Roman
Hey r0man,
I'd replace react-fn
with a multimethod:
https://github.com/r0man/sablono/blob/master/src/sablono/compiler.clj#L72
that way the user could extend it to different tags.
Hi Sam,
makeing react-fn a multimethod is not a big deal. However, I think we need a better name for the function. Patch with tests welcome, and ideally without any additional dependencies.
Roman
Okay, I should have some time to play with this in the next week or so. Thanks!
Updates?
Haven't worked on this, but converting that function to a multimethod should do it easily.
I'd also love to be able to plug custom element tags into sablono.
If this is hung up on deciding on a name, how about element-constructor
?
I think it's just hung up on someone coding up the multimethod implementation. I'm just not using sablono in my work, so haven't gotten around to it.
— Sent from Mailbox
On Fri, Jul 31, 2015 at 4:00 PM, Darrick Wiebe [email protected] wrote:
I'd also love to be able to plug custom element tags into sablono.
If this is hung up on deciding on a name, how about
element-constructor
?Reply to this email directly or view it on GitHub: https://github.com/r0man/sablono/issues/46#issuecomment-126831065
I would really like this feature because then you can plug-in different renderers and do things closer to jsx: https://react.semantic-ui.com/views/card#card-example-card
[:sem/card
[:sem/image ...]
[:sem/card.header]]
I'm in love with the idea of allowing qualified keywords as sablono hiccup tag names, to call constructor functions but there is a big caveat: the sablono interpreter + advanced optimization:
Since clojurescript function names are subject to renaming, but keywords aren't, the interpreter won't be able to construct such elements, unless all used constructor functions are marked ^:export
.
This is really sub-optimal, but maybe rum and om can be persuaded to change their def*
forms accordingly ...