A simple Blade directive for Laravel that allows you to render components and HTML directly to a PHP variable from within a Blade view. This is particularly useful for passing dynamic content to Livewire components or other parts of your application.
You can install the package via Composer:
composer require doob-code/laravel-blade-snippets
This package will automatically register its service provider, but if you need to do it manually, add the service provider to your config/app.php
file:
'providers' => [
// ...
DoobCode\BladeSnippets\BladeSnippetServiceProvider::class,
],
Use the @snip
and @endsnip
directives to capture Blade components or HTML into a variable.
@snip('popoverContent')
<x-popover>Dynamic section content here</x-popover>
@endsnip
<!-- Pass the $popoverContent variable to a Livewire component -->
@livewire('valuation.next-page-button', [
'disabled_popover' => $popoverContent,
])
When using the directives, make sure to provide a variable name without extra quotes. The directive automatically trims surrounding quotes.
This package is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or enhancements.
- Laravel framework
- Blade templating engine