You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/each-block-containing-if/main.html

23 lines
550 B

<script>
export let items = [
{ description: 'one', completed: false },
{ description: 'two', completed: false },
{ description: 'three', completed: false }
];
export let currentFilter = 'completed';
function filter(item, currentFilter) {
if ( currentFilter === 'all' ) return true;
if ( currentFilter === 'completed' ) return item.completed;
if ( currentFilter === 'active' ) return !item.completed;
}
</script>
<ul>
{#each items as item}
{#if filter(item, currentFilter)}
<li>{item.description}</li>
{/if}
{/each}
</ul>