This is a simple output buffering directive for Laravel's Blade templating engine. It can be used to buffer output (e.g. from other directives) into a variable.
The @buffer
directive starts buffering output, the @endbuffer
directive stops it. @endbuffer
also takes a variable name as an optional parameter to store the buffered output in. If no variable name is provided, all buffered output will be discarded.
The concrete example that sparked the idea for this directive was to take a Blade template with SVG contents and use it as a Base64 encoded SVG favicon — like this:
@buffer
@include('icons.laravel', [ 'fill' => '#ff2d20' ])
@endbuffer('icon')
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,{{ base64_encode($icon) }}" sizes="any">