Slots

Slots define placeholders in layouts that can be dynamically filled with templates. They are the foundation of layout composition.

---

1. Basic Slot

<div data-slot="content"></div>

$tpl->slot('content', 'home');
---

2. Nested Slots


$admin = $tpl->slot('content', 'admin');
$dashboard = $admin->slot('content', 'dashboard');

Structure:

base → admin → dashboard
---

3. Slot with Data Binding


$page = $tpl->slot('content', 'home');
$page->pick('title')->content('Dashboard');
---

4. Slot with Path


$tpl->slot('content', 'home', 'pages');
---

5. Slot Inside Slot

Child templates can define their own slots.

---

6. Common Mistakes

❌ Missing data-slot in layout
❌ Duplicate slot names
❌ Wrong slot name
❌ Rendering child before parent
---

7. Rules

---

8. Best Practices

---
Slots are the backbone of layout composition.