Summary
A @slot('name') directive placed inside a @section('name') block is never resolved — it gets merged into the layout verbatim and renders as the literal string @slot('name') on the page. This breaks the common "parent view as a nested-route layout" pattern, where a view holds a @slot('content') placeholder to receive its child/tab content.
Root cause (src/process.ts)
Two passes run, in this order, over the view output:
- Sections are extracted and removed from
output(~line 677): the@section('name') … @endsectionreplace stores the body into asectionsmap and the callbackreturn ''s — so the section body (and anything inside it) is pulled out ofoutput. - The slot resolver runs over
output(~line 692):output = output.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g, (_, name, defaultContent) => sections[name] || defaultContent || '')
Because step 1 already removed section bodies from output, any @slot(…) that lived inside a section is no longer in output when step 2 runs — it's never resolved. When the section body is later injected into the layout (the @yield/@slot substitution around lines ~800–840), the nested @slot(…) is emitted as-is → literal text.
Note the resolver already collapses an unfilled slot to '' (sections[name] || defaultContent || ''), so the intended behavior for an empty slot is "render nothing." The bug is solely that slots nested in sections never reach the resolver.
Reproduction
A view that uses @slot inside its own @section('content') — e.g. a parent view acting as a nested-route / tab layout:
@extends('layouts/default')
@section('content')
<h1>Profile</h1>
<nav>…tabs…</nav>
@slot('content') {{-- expected: child/tab content, or empty; actual: literal "@slot('content')" --}}
@endsectionThe rendered HTML contains the literal text @slot('content').
Impact
Any "parent view as nested-route layout" leaks the directive. In our app, the judge and courthouse profile pages (judges/[id].stx, court-houses/[id].stx) hold a @slot('content') inside their @section('content') to render their /reviews, /cases, /profile tab children. On a tab route the child fills it; but on the base route (no child), the literal @slot('content') renders on the page.
Suggested fix
Resolve @yield/@slot inside section bodies too — either run the slot-resolution replace over each extracted section's content inside the line-~677 callback before storing it into sections, or re-run the resolver after sections are merged into the layout, so nested (and unfilled) slots collapse to their default or empty string.
Version
@stacksjs/stx 0.2.70