Skip to content

Commit

Permalink
fix: dont evaluate contents twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangjchandler committed May 22, 2021
1 parent de58434 commit 87f83ad
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/BladeCacheDirectiveServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,22 @@ public function packageBooted()
if (\Illuminate\Support\Facades\Cache::has(\$__cache_directive_key)) {
echo \Illuminate\Support\Facades\Cache::get(\$__cache_directive_key);
ob_start();
} else {
\$__cache_directive_buffering = true;
ob_start();
}
?>";
});

Blade::directive('endcache', function () {
return "<?php
if (isset(\$__cache_directive_buffering)) {
\$__cache_directive_buffer = ob_get_clean();
\Illuminate\Support\Facades\Cache::put(\$__cache_directive_key, \$__cache_directive_buffer, \$__cache_directive_ttl);
echo \$__cache_directive_buffer;
unset(\$__cache_directive_key, \$__cache_directive_ttl, \$__cache_directive_buffering, \$__cache_directive_buffering, \$__cache_directive_arguments);
} else {
ob_end_clean();
unset(\$__cache_directive_key, \$__cache_directive_ttl, \$__cache_directive_buffer, \$__cache_directive_buffering, \$__cache_directive_arguments);
}
?>";
});
Expand Down

0 comments on commit 87f83ad

Please sign in to comment.