Guide › Templates

Slots

A component without a script can wrap content: whatever you put between its tags renders at its <slot />.

{{-- components/card.tscl --}}
<section class="card"><slot /></section>

{{-- a page --}}
<card><p>Inside the card.</p></card>

The content belongs to the page that writes it, so its holes read the page's inputs. This is how layouts work: this site's layout is a component, and every page wraps its content in it.

Named slots

Give slots names, and fill them from the parent with @slot('name') { … }; everything else goes to the default slot. Content inside a <slot> is the fallback, shown when nothing fills it.

{{-- components/panel.tscl --}}
<section>
  <header><slot name="head">Untitled</slot></header>
  <slot />
</section>

{{-- a page --}}
<panel>
  @slot('head') { <h2>Settings</h2> }
  <p>Everything else is the default slot.</p>
</panel>