Reference › Templates
Template syntax
Everything you can write in a .tscl file, with links to the guide.
| Syntax | What it does | Guide |
|---|---|---|
@input name: Type = default | a typed input | Inputs |
@import name from './x.tscl' | use a component | Components |
@import { a } from './x.ts' | import data | Components |
@import type { T } from './x' | import types for inputs | Inputs |
{{ expr }} | print a value, escaped | Holes |
[name]="expr", name="a {{ b }}" | bind an attribute or a component input | Attributes |
(event)="handler" | handle an event (islands) | Islands |
@if (a) { } @else if (b) { } @else { } | conditional branches | Conditionals |
@for (x of xs; track x.id) { } @empty { } | repeat content | Lists |
<slot />, <slot name="x">fallback</slot> | where wrapped content goes | Slots |
@slot('x') { } | fill a named slot | Slots |
verbatim attribute | show content as text | Verbatim |
<script> … </script> | make a component interactive | State |
<script inline> … </script> | a script written out as is, run where it stands | Styles |
<style> … </style>, <style global> | the component's CSS, scoped (or global) | Styles |
{{-- comment --}} | a template comment, removed from the output |