utkarshkukreti / markup.rs

A blazing fast, type-safe template engine for Rust.
Apache License 2.0
350 stars 14 forks source link

Add @match #1

Closed utkarshkukreti closed 5 years ago

utkarshkukreti commented 5 years ago

Test case:

@for x in &[(1, 2), (3, 3), (5, 4), (0, 1)] {
    @match x {
        (1, 2) => "1 -> 2\n",
        (x, y) if x == y => { "eq" "\n" },
        (x, y) if x == y + 1 => {
            div { {x} {y} } "\n"
        }
        _ => "!\n"
    }
}

Output:

1 -> 2
eq
<div>54</div>
!