Moe-js v0.3

Expressions

Moe-js templates are similar to Mustache/Handlebars templates, but there are some important differences. This section shows how to write Moe-js templates.

Use {{}} to Embed Expressions

Use {{ and }} to delimit expressions:

<p>10 + 20 = {{ 10 + 20 }}</p>

Any valid JavaScript expression can be used:

<p>sin(0.5) = {{ Math.sin(0.5) }}</p>

Escaped vs Non-Escaped Output

Double braces cause the rendered text to be HTML encoded:

<p>{{"<blah>"}}<p>

Results in:

<p>&lt;blah&gt;</p>

Use triple braces to suppress encoding:

<p>{{{"<br/>"}}}</p>

Results in:

<p><br/></p>

Subscribe for more like this. No spam, just fun tech stuff :)

Or, find me on Twitter: @toptensoftware.