Core DevPre-alpha
Sum template (.sum.xml)
SWC includes a compile-time template language for addon and core components. Files use the .sum.xml extension and compile to TypeScript html tagged literals via the esbuild plugin in core/swc/esbuild.config.mjs.
When to use
| Approach | Use when |
|---|---|
html in .ts` | Most field widgets and views (default) |
.sum.xml | Larger templates with many conditionals or loops |
Core views use html` directly; sum-template is optional for addon authors who prefer XML-like markup.
Directives
| Directive | Compiles to |
|---|---|
t-if="expr" | when(expr, () => html…) |
t-elif="expr" | Chained when |
t-else | Else branch of when |
t-foreach="item in items" t-key="item.id" | forEach(items, …) |
t-esc="expr" | ${expr} (escaped) |
t-raw="expr" | ${expr} |
t-model="expr" | Two-way @input + value bind |
t-component="MyComponent" | mountComponent(MyComponent, …) |
t-ref="name" | data-ref="name" attribute |
t-portal="target" | data-portal="target" attribute |
t-slot="name" | data-slot="name" attribute |
{{ expr }} | Interpolation |
Example
MyPanel.sum.xml:
<div class="sum-my-panel">
<div t-foreach="item in items" t-key="item.id">
<span t-if="item.active">{{ item.name }}</span>
</div>
</div>
Compiles to a TypeScript module exporting a template function used by SwcComponent.template().
Limitations
t-slot,t-portal, andt-refemit data attributes only — there is no runtime slot-filling or portal API yet.t-modelis compile-time binding; no centralized v-model runtime.- Compiler lives in
core/swc/src/template/sum/; tests intests/template/sum-compiler.test.ts.
Build
Sum files are processed during make swc / npm run build in core/swc. Addon packages can copy the esbuild plugin from sum-compile.mjs.