<div if.bind="isLoading">Loading...</div>
<div if.bind="user.isAuthenticated">Welcome back, ${user.name}!</div><div if.bind="user.isAuthenticated">
Welcome back, ${user.name}!
</div>
<div else>
Please log in to continue.
</div><custom-element if="value.bind: canShow; cache: false"></custom-element><div show.bind="isDataLoaded">Data loaded successfully!</div>
<div show.bind="!isLoading">Content is ready</div><div hide.bind="isHidden">Hidden when true</div><div show.bind="!isHidden">Hidden when true</div><!-- Use show.bind for frequent toggles -->
<div show.bind="isExpanded">
<expensive-component></expensive-component>
</div>
<!-- Use if.bind for infrequent changes -->
<admin-panel if.bind="user.isAdmin"></admin-panel>// Status.ts
enum OrderStatus {
Received = 'received',
Processing = 'processing',
Dispatched = 'dispatched',
Delivered = 'delivered'
}<!-- order-status.html -->
<template switch.bind="orderStatus">
<span case="received">Order received</span>
<span case="processing">Processing your order</span>
<span case="dispatched">On the way</span>
<span case="delivered">Delivered</span>
<span default-case>Unknown status</span>
</template><template switch.bind="orderStatus">
<span case.bind="['received', 'processing']">
Order is being processed
</span>
<span case="dispatched">On the way</span>
<span case="delivered">Delivered</span>
</template><template switch.bind="orderStatus">
<span case="received" fall-through="true">Order received</span>
<span case="processing">Processing your order</span>
</template><template repeat.for="num of numbers">
<template switch.bind="true">
<span case.bind="num % 15 === 0">FizzBuzz</span>
<span case.bind="num % 3 === 0">Fizz</span>
<span case.bind="num % 5 === 0">Buzz</span>
<span default-case>${num}</span>
</template>
</template><template as-custom-element="status-card">
<au-slot name="content"></au-slot>
</template>
<status-card>
<template au-slot="content" switch.bind="status">
<div case="loading">Loading...</div>
<div case="error">Something went wrong</div>
<div case="success">Operation completed</div>
</template>
</status-card><template switch.bind="userRole">
<div case="admin">
<template switch.bind="adminSection">
<admin-users case="users"></admin-users>
<admin-settings case="settings"></admin-settings>
<admin-dashboard default-case></admin-dashboard>
</template>
</div>
<user-dashboard case="user"></user-dashboard>
<guest-welcome default-case></guest-welcome>
</template><!-- Good: Group related conditions -->
<template switch.bind="appState">
<loading-screen case="loading"></loading-screen>
<error-screen case="error"></error-screen>
<main-content case="ready"></main-content>
</template>
<!-- Avoid: Multiple separate if statements -->
<loading-screen if.bind="appState === 'loading'"></loading-screen>
<error-screen if.bind="appState === 'error'"></error-screen>
<main-content if.bind="appState === 'ready'"></main-content><!-- âś… Correct -->
<template switch.bind="status">
<span case="active">Active</span>
</template>
<!-- ❌ Incorrect: case not direct child -->
<template switch.bind="status">
<div if.bind="someCondition">
<span case="active">Active</span>
</div>
</template><template switch.bind="status">
<span case="received">Received</span>
<span case="processing">Processing</span>
<span default-case>Unknown</span> <!-- Last -->
</template>