Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Can you add optional _outer_ tags in svelte conditional statement?

$
0
0

Is it possible to use a conditional statement to wrap inner content with an optional outer element?

Here is an example of what I want to do in valid Svelte:

<script>  export let needs_div_wrapper;</script>{#if needs_div_wrapper}<div><a>My static content!</a></div>{:else}<a>My static content!</a>{/if}

And here is an example in non-valid Svelte that demonstrates what I want to do:

...{#if needs_div_wrapper}<div>{/if}<a>My static content!</a>{#if needs_div_wrapper}</div>{/if}

EDIT: Just for clarity, I'm trying to accomplish this without a new component for the inner content.


Viewing all articles
Browse latest Browse all 1541

Trending Articles