Skip to content

Fix conditional slots being always rendered#134

Draft
ganyicz wants to merge 1 commit intomainfrom
filip/compiled-slots
Draft

Fix conditional slots being always rendered#134
ganyicz wants to merge 1 commit intomainfrom
filip/compiled-slots

Conversation

@ganyicz
Copy link
Collaborator

@ganyicz ganyicz commented Mar 13, 2026

Draft — this doesn't handle folded components yet. Slots inside conditionals will still always render when the component is folded. To fix this, we need to statically analyze the component and abort the fold when a slot is conditionally rendered.

The scenario

Wrapping <x-slot> in @if always renders the slot, even when the condition is false.

<x-card>
    @if(false)
    <x-slot name="header">
        Header
    </x-slot>
    @endif
</x-card>

The problem

Blaze extracted slot declarations at compile time, stripping them from their surrounding Blade directives. Runtime conditionals like @if were never evaluated around the slot.

The solution

We now compile slots inline alongside the rest of the template instead of extracting them upfront.

Fixes #119

@ganyicz ganyicz marked this pull request as draft March 13, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<x-slot> inside @if is always rendered when Blaze is enabled

1 participant