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

Render fragments #14

Closed
garuse opened this issue Jan 22, 2024 · 3 comments
Closed

Render fragments #14

garuse opened this issue Jan 22, 2024 · 3 comments

Comments

@garuse
Copy link

garuse commented Jan 22, 2024

I found a use case that does not seem to be supported by sprae: fragments rendering.

I want to render two table rows at a time, in a loop:

<template :ref="row">
  <tr><td>col1</td><td>col2</td></tr>
  <tr><td :text="data"></td></tr>
</template>

I cannot use a single tag as parent because it will break the table structure, so I would like something similar with Alpine:

<template x-for="post in posts">
  <h2 x-text="post.title"></h2>
</template>

Is it possible to implement something like this?

<template :each="i in 3" :ref="row" :with="{data: rowdata}"></template>

Thank you!

@dy
Copy link
Owner

dy commented Jan 23, 2024

Thanks for the good use-case. It must be possible. This and also easy declaring components like <template :define=my-elem'>...</template> would give another sense to sprae - template directives. Also that would allow <template :if=xxx>...</template>.

I have to meditate on that. Not sure what meaning <template> should have - is that immediate or for definitions? Is that fragment or custom element? Gotta research known use-cases. It seems like mixed concerns for now.

@dy
Copy link
Owner

dy commented Jan 23, 2024

It seems from declarative shadow dom and declarative custom elements template is used more like fragment boundary, rather than definition.

Also <template :if=xxx looks like <template directive=if expression=xxx from template-instsntiation proposal, which assumes templates within templates - it is used as fragment there as well.

@dy
Copy link
Owner

dy commented Mar 6, 2024

Ok, done in v9.

@dy dy closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants