Skip to content

Add some way to compose selectors #52

@levand

Description

@levand

Say I have something like this:

 (defsnippet Container "template.html" [:.container]
  [data]
  {[:.widget1 :.foo] (content "foo")
   [:.widget1 :.bar] (content "bar")
   [:.widget2 :.foo] (content "foo")
   [:.widget2 :.bar] (content "bar")})

Is there a way to factor out the common elements? Something like this, perhaps?

(def selector-fragment
  {[:.foo] (content "foo")
   [:.bar] (content "bar")})

(defsnippet Container "template.html" [:.container]
  [data]
  {[:.widget1] (selector-fragment)
   [:.widget2] (selector-fragment)})

I don't care about the syntax, but I can't figure out any way to get this kind of composition/abstraction without hacking Kioo itself.

  1. If I do the composition in "transform" position, on the right hand side, I can't do any more selecting because selection is unavailable at runtime.
  2. I can't compose on the left hand side, in the selector position, because evaluation of that is controlled exclusively by the Kioo macro.

Any ideas on how this might be supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions