" => html }
${ new Date() => date }
${ "foo" => repeat(3) }
${ " foo&bar " => trim, upcase, html
=> embed("=>}) ", // line comment
" ({<=")
}
$(BLOCK table(cols)
$(MAP (label => cols) $label | $)
$(CONTENT)
$)
$(WRAP table([ "Name", "Phone", "Email" ])
Foo | 123-1234 | foo@foo.com |
Bar | 1234-123 | bar@bar.com |
$)
$(BLOCK wrapper()
$(CONTENT)
$)
$(REPEAT (5 => i)
$(WRAP wrapper()
Wrapped $i time
$)$)
$(BLOCK display_sum(a, b)
$a + $b = ${a + b}
$)
${ display_sum(10, 20) }
$(WITH (this)
${/* boring comment that is scratched from the output */}
${}
Literal $$.
$(VAR (counter2))
$(LET ((value => 0))
$( counter2 = _counter /* export it */ )
$(BLOCK _counter()
Counter is ${ ++value }
$) $)
$(REPEAT (5)
$( counter2() ) -- now it works.
$)
$(REPEAT (5 => i) Take $i! $)
$(REPEAT ( (function /*heavy_computation*/() { return 5 })() => i )
Foo $i $)
$(REPEAT (2..4 => i) Now $i! $)
$(WITH ({ foo: "ba\"r" })
Foo is $foo
$)
$(MAP ([ 1, 2, 3, 4 ])
We have $_
$-
$)
$(IF (false)
You should not see this
$(ELSIF (false))
This neither
$(ELSE)
You SHOULD see this
$)
$(
var my_var = "foo";
var your_var = "bar";
// do whatever you want here.
)
$(VAR ((v_foo => 10)
v_bar
(v_baz => 20)))
${v_foo}, ${v_bar}, ${v_baz}
$(MAP ([{ foo: "bar" }, /* comment,:}*/ { foo: "test" }])
We have: $foo (and my_var is “$my_var”)
$)
${
// whatever(.
(function(arg){
return foo.bar.baz(1, 2, "(3") + arg.test;
/* foo ]] */
})({ test: "foo)" })
}
$(IF (foo.list)
$(MAP (index, element => foo.list)
- ** ${index + 1}. ${element}
$)
$)
Inline maphash
$(MAPHASH (key, val => {
key1 : "val1",
key2 : "val2",
key3 : "val3"
})
${key} : ${val}
$)
$(LET ((v1 => "")
(v2 => ""))
$v1, ${ v2 => html }
$(LET ((v1 => "shadow"))
New v1: $v1
$)
Back: $v1
$)
$(BLOCK this_is_a_function(a, b)
Got arguments: $a and $b
$)
${ this_is_a_function("foo", "bar") }
$(LET ((foo => (function(){
return (function(){
return "foo(bar[baz";
})();
})()))
GOT: $foo
$)
$-
$(IF (true)
foo$-
$(ELSE)
bar
$)
$)
$(SWITCH ("f1")
$(CASE ("j1")
yo yo, we don't get here $)
$(CASE ("f1")
but we get here $)
$(DEFAULT
not here this time $)
$)