Skip to content

Commit

Permalink
use loadOnce instead of bassetBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
pxpm committed Jul 16, 2024
1 parent 6edb1c2 commit f4779b3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/BassetServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,11 @@ protected function registerBladeDirectives()

// Basset Code Block
$bladeCompiler->directive('bassetBlock', function (string $parameter): string {
$parameters = array_map('trim', explode(',', $parameter));
$blockName = $parameters[0];
// keep cache as true by default when not provided in block definition
$cacheOption = $parameters[1] ?? true;

return "<?php \$bassetBlock = {$blockName}; \$cache = {$cacheOption}; ob_start(); ?>";
return "<?php \$bassetBlock = {$parameter}; ob_start(); ?>";
});

$bladeCompiler->directive('endBassetBlock', function (): string {
return '<?php Basset::bassetBlock($bassetBlock, ob_get_clean(), true, $cache); ?>';
return '<?php Basset::bassetBlock($bassetBlock, ob_get_clean()); ?>';
});

// DEPRECATED - Please use `@basset` or `@bassetBlock`. @loadOnce Will be completely removed in Backpack v7.
Expand All @@ -135,7 +130,7 @@ protected function registerBladeDirectives()
});

$bladeCompiler->directive('endLoadOnce', function (): string {
return '<?php Basset::bassetBlock($bassetBlock, ob_get_clean()); ?>';
return '<?php Basset::bassetBlock($bassetBlock, ob_get_clean(), true, false); ?>';
});

$bladeCompiler->directive('loadStyleOnce', function (string $parameter): string {
Expand Down

0 comments on commit f4779b3

Please sign in to comment.