Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dereferencing tags' children in DSL 🔥 #194

Closed
quimt opened this issue Nov 25, 2023 · 1 comment
Closed

Dereferencing tags' children in DSL 🔥 #194

quimt opened this issue Nov 25, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@quimt
Copy link

quimt commented Nov 25, 2023

Is your feature request related to a problem? Please describe. 🤔
Now that buildHtml can generate fragments of DSL code, the next natural thing to do with them is to place them in more complex data structures other than simple assignments. Procs returning TagRefs and seqs/sets/tables of TagRefs are all valuable, but if simplicity is a priority, then simply having a convenient way to de-reference children would be enough.

Given that components can only have one slot, for example, accessing the children of slot allows components to have a variable number of TagRef arguments and post them to the page in more selective and complex ways.

Currently we can access children and assign to a variable, but cannot use [] directly to place a TagRef:


appRoutes("ROOT"):
  "/":
    let myList = buildHtml:
      tDiv: "a"
      tDiv: "b"
      tDiv: "c"
    let myItem = myList.children[2]
    myItem
    # myList.children[2]

The code will run and selects tDiv: "c", but the commented code fails. Currently the compiler says it expected an identifier but didn't get one; ideally it seems we want to allow any call that returns a static string or a Component or a TagRef

@quimt quimt added the enhancement New feature or request label Nov 25, 2023
@Ethosa
Copy link
Contributor

Ethosa commented Nov 27, 2023

Since next commit you can do all of it with {} syntax:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants