Control flow

If expressions

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

fun User(User user) -> HTML
{
    <div>
        @if user.verified
        {
            <p>Hello {user.name}</p>
        }
        @else
        {
            <p>Verify your account to continue</p>
        }
    </div>
}thp
    
Syntax error: Expected an identifier after the `fun` keyword. at line 1:4

Loops

Use @for:

fun Users() -> HTML
{
    val users = User::get_all()

    <div>
        @for user in users
        {
            <User user={user} />
        }
    </div>
}thp
    
Syntax error: Expected an identifier after the `fun` keyword. at line 1:4

Match

Use @match for pattern matching:

fun UserDetail(User user) -> HTML
{
    <div>
        @match user.type
        @case ::Admin
        {
            <button>Delete resource</button>
        }
        @case ::User
        {
            <button disable>Not allowed</button>
        }
    </div>
}thp
    
Syntax error: Expected an identifier after the `fun` keyword. at line 1:4