Template syntax
Control flow for HTML
HTML plus a handful of control-flow blocks, interpolation and bindings. That is the whole language; the compiler adds no components, layouts or partials.
The context object
Every template reads its input from a single top-level name, context. There is no implicit alias and no global scope. Whatever your host passes in becomes context.
// Astro: the value of context={...} is the template's `context`
<template flowview={{ title: "Hi", items }} is:raw>
<h1>{{ context.title }}</h1>
</template>
// JavaScript target: the argument of render()
render({ title: "Hi", items });Interpolation
{{ value }} is escaped, so markup in the value renders as text. It is the default.
{{{ value }}} inserts a string verbatim. It is for HTML you already trust, and FlowView never sanitizes it. Raw interpolation works in element content only, not inside attributes or tag names.
Write \@if or \{{ to output the marker literally.Read the security model →
<p>{{ context.title }}</p> <!-- escaped -->
<div>{{{ context.bodyHtml }}}</div> <!-- raw, trusted -->@if, @else if, @else
Conditions are JavaScript expressions. The first branch that is truthy renders. In the native Rust target, the same conditions are limited to a deterministic subset (property paths, literals, comparisons, !, &&,||, ??).
@if (context.user) {
<p>Hello {{ context.user.name }}</p>
} @else if (context.guest) {
<p>Welcome, guest</p>
} @else {
<p>Please sign in</p>
}@for, track, @empty
Iterate arrays, and in the JavaScript target any iterable. @empty renders when there are no items.
track is accepted syntax. Today it has no runtime effect, because FlowView renders strings and does not diff DOM nodes, and the compiler reports it as a warning.
@for (item of context.items; track item.id) {
<li>{{ item.title }}</li>
} @empty {
<li>Nothing here yet</li>
}@switch, @case, @default
Compare one expression against several cases. @default handles everything else.See it rendered →
@switch (context.status) {
@case ('draft') { <span>Draft</span> }
@case ('published') { <span>Published</span> }
@default { <span>Unknown</span> }
}Bindings
Bindings are evaluated at render time. They are not DOM property bindings: [disabled] adds or removes the attribute in the HTML string. The boolean attribute set is disabled, hidden, checked,selected, required, readonly, multiple andopen.
<button [disabled]="context.loading">Save</button><div [class.active]="context.selected">...</div><section [attr.aria-busy]="context.loading">...</section><a href="{{ context.profileUrl }}">Profile</a>Event syntax such as (click) belongs to the separate Events compiler.
What the compiler produces
The JavaScript target emits a module exporting render(context), which returns an HTML string and imports a few escaping helpers from @flowview/runtime. The native Rust target renders the same language to HTML directly. Both are held to one specification.
import { renderValue } from "@flowview/runtime";
export function render(context) {
let output = "";
// ... generated from your template
return output;
}