Setting the file. One moment.
Chapter 04 · Svelte Core Bestpractices
Subchapter 4.7
references/render.mdMarkdown841 BView on GitHub
To render a snippet (opens in a new tab), use a {@render ...} tag.
{#snippet sum(a, b)}
<
The expression can be an identifier like sum, or an arbitrary JavaScript expression:
{@render (cool ? coolSnippet : lameSnippet)()}If the snippet is potentially undefined — for example, because it’s an incoming prop — then you can use optional chaining to only render it when it is defined:
{@render children?.()}Alternatively, use an {#if ...} (opens in a new tab) block with an :else clause to render fallback content:
{#if children}
{@render children()}
{:else}
<p>fallback content</p>
{/if}