Skip to content

Commit

Permalink
Add $__bladeCompiler to function uses
Browse files Browse the repository at this point in the history
  • Loading branch information
konradkalemba committed Sep 13, 2024
1 parent 057f062 commit d66b44a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/BladeComponentsScopedSlotsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ public function boot()

// Connect the arguments to form a correct function declaration
if ($functionArguments) $functionArguments = "function {$functionArguments}";

$functionUses = array_filter(explode(',', trim($functionUses, '()')), 'strlen');
// Add `$__env` to allow usage of other Blade directives inside the scoped slot

// Add `$__env` and `$__bladeCompiler` to allow usage of other Blade directives inside the scoped slot
array_push($functionUses, '$__env');
array_push($functionUses, '$__bladeCompiler');

$functionUses = implode(',', $functionUses);

return "<?php \$__env->slot({$name}, {$functionArguments} use ({$functionUses}) { ?>";
return "<?php \$__bladeCompiler = \$__bladeCompiler ?? null; \$__env->slot({$name}, {$functionArguments} use ({$functionUses}) { ?>";
});

Blade::directive('endscopedslot', function () {
return "<?php }); ?>";
});
}
}
}

0 comments on commit d66b44a

Please sign in to comment.