feat(layout): render empty variant slots
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-03 16:21:46 +00:00
parent b3f622988d
commit baca8f26cf
2 changed files with 13 additions and 3 deletions

View file

@ -80,9 +80,6 @@ func (l *Layout) Render(ctx *Context) string {
for i := range len(l.variant) {
slot := l.variant[i]
children := l.slots[slot]
if len(children) == 0 {
continue
}
meta, ok := slotRegistry[slot]
if !ok {

View file

@ -114,3 +114,16 @@ func TestLayout_IgnoresInvalidSlots(t *testing.T) {
t.Errorf("C variant should ignore R slot content, got:\n%s", got)
}
}
func TestLayout_RendersEmptySlots(t *testing.T) {
ctx := NewContext()
layout := NewLayout("HCF")
got := layout.Render(ctx)
for _, want := range []string{`<header role="banner" data-block="H-0"></header>`, `<main role="main" data-block="C-0"></main>`, `<footer role="contentinfo" data-block="F-0"></footer>`} {
if !strings.Contains(got, want) {
t.Errorf("empty slot should still render %q in:\n%s", want, got)
}
}
}