feat(layout): render empty variant slots
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
b3f622988d
commit
baca8f26cf
2 changed files with 13 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue