Control Flow
Conditional rendering
Add an if attribute to any element to render it conditionally:
return <>
<p if={{ user.is_admin }}>Admin panel</p>
<p if={{ not user.is_verified }}>Please verify your email.</p>
</>
The element is omitted entirely from the output when the condition is false.
Loops
Add a for attribute to repeat an element over any iterable:
if and for can be combined on the same element:
Components
if and for work on component tags too:
They are purely structural — the transpiler handles them before the call is emitted, so neither if nor for is ever passed as a keyword argument to the component function.