soma.cell

Templates

Templates, in the reference of the Soma programming language (soma 3.2.4). A block marked ✓ is a whole program that soma check accepts; the others are excerpts.

A template is a string with {name} placeholders. In a string literal, {…} is interpolation, so write the placeholder with doubled braces: the literal "Hello, {{name}}!" is the text Hello, {name}!, which render fills.

let tpl = "Hello, {{name}}!"              // the text: Hello, {name}!
let s = render(tpl, "name", "Ada")        // "Hello, Ada!"
let s = render_each(rows, "<li>{{n}}</li>")   // the template once per map in the list, joined

Writing "Hello, {name}!" instead is error E0011: name is read as a variable of the handler.