A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://svelte.dev/docs/svelte/@render below:

{@render ...} • Docs • Svelte

To render a snippet, use a {@render ...} tag.

{#snippet sum(a, b)}
	<p>{a} + {b} = {a + b}</p>
{/snippet}

{@render sum(1, 2)}
{@render sum(3, 4)}
{@render sum(5, 6)}

The expression can be an identifier like sum, or an arbitrary JavaScript expression:

{@render (cool ? coolSnippet : lameSnippet)()}
Optional snippets

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:

Alternatively, use an {#if ...} block with an :else clause to render fallback content:

{#if children}
	{@render children()}
{:else}
	<p>fallback content</p>
{/if}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4