Control flow

If expressions

Use @if, @else if and @else to branch during the template creation.


fun User(User user) -> HTML
╰╴No statement matched
{ <div> @if user.verified { <p>Hello {user.name}p> } @else { <p>Verify your account to continuep> } div> }
thp

Loops

Use @for:


fun Users() -> HTML
╰╴No statement matched
{ val users = User::get_all() <div> @for user in users { <User user={user} /> } div> }
thp

Match

Use @match for pattern matching:


fun UserDetail(User user) -> HTML
╰╴No statement matched
{ <div> @match user.type @case ::Admin { <button>Delete resourcebutton> } @case ::User { <button disable>Not allowedbutton> } div> }
thp