sablono icon indicating copy to clipboard operation
sablono copied to clipboard

Custom Tags

Open sritchie opened this issue 10 years ago • 10 comments

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?

sritchie avatar Dec 10 '14 16:12 sritchie

Hi Sam, could you provide more details on how this should work? Roman

r0man avatar Dec 12 '14 14:12 r0man

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.

sritchie avatar Dec 12 '14 18:12 sritchie

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

r0man avatar Dec 22 '14 12:12 r0man

Okay, I should have some time to play with this in the next week or so. Thanks!

sritchie avatar Dec 22 '14 15:12 sritchie

Updates?

dsvensson avatar Jul 01 '15 22:07 dsvensson

Haven't worked on this, but converting that function to a multimethod should do it easily.

sritchie avatar Jul 01 '15 23:07 sritchie

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?

pangloss avatar Jul 31 '15 23:07 pangloss

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

sritchie avatar Aug 01 '15 00:08 sritchie

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]]

zcaudate avatar Jun 09 '17 02:06 zcaudate

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 ...

bendlas avatar Jul 06 '17 19:07 bendlas