Use conditions and escaping in views
Views are HTML with @{...} blocks. A condition is @{if expression}, optionally @{else}, and always closed with @{fi}. The expression is plain JavaScript and can use model (the data passed to $.view()), repository (values shared with the layout), query, user, config and language.
Output is escaped by default: @{model.text} turns < into <, which protects you from injection. Put a ! after @{ to send the raw value (@{!model.html}) and do it only with content you trust.
@{layout('')}
@{if model.admin}
<p class="role">Administrator</p>
@{else}
<p class="role">Guest</p>
@{fi}
@{if model.items.length > 2}
<p class="many">many items</p>
@{fi}
<div class="escaped">@{model.text}</div>
<div class="raw">@{!model.text}</div>exports.install = function() {
ROUTE('GET /{role}/', page);
};
function page($) {
$.view('index', { admin: $.params.role === 'admin', items: [1, 2, 3], text: 'Hello <b>World</b>' });
}