Skip to content

Render children but without {@render children} #14929

@NaviTheCoderboi

Description

@NaviTheCoderboi

Describe the problem

I am trying to implement react-spectrum's collections for svelte , I know that react is very different from svelte , but I am doing it my own way , I want to build up a collection(a list of items) from the children Snippet passed to a component , but I need to wait for it to be rendered and use dom APIs , but I want to build it beforehand if it's SSR, like get content of a children snippet in format of a string and a utility to transform it to a Dom tree/element. It would be useful for my usecase , and open up more usecase for it.

Describe the proposed solution

Svelte can allow users to render children the script , like a utility for it , something like ,

<script>
  const content = $render(children)
</script>

It can be a function/rune type from svelte. It can return a rendered string of the children , and svelte can either provide some utility to parse it to a Dom tree or leave it to user to handle it. And lator user can render it in template using {@html content}

If it it not possible, please let me know why , and a alternate solution to it.

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions