Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ Blaze supports all essential features and produces HTML output identical to Blad
- **Class-based components** are not supported
- **The `$component` variable** is not available
- **View composers / creators / lifecycle events** do not fire
- **Auto-injecting `View::share()` variables** is not supported

Access shared data manually using `$__env->shared('key')`
- **Cross boundary `@aware`** between Blade and Blaze

Both parent and child must use Blaze for values to propagate
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function wrap(string $compiled, string $path, ?string $source = null): st
$output .= 'if (($__data[\'attributes\'] ?? null) instanceof \Illuminate\View\ComponentAttributeBag) { $__data = $__data + $__data[\'attributes\']->all(); unset($__data[\'attributes\']); }'."\n";
$output .= 'extract($__slots, EXTR_SKIP); unset($__slots);'."\n";
$output .= 'extract($__data, EXTR_SKIP);'."\n";
$output .= 'extract($__env->getShared(), EXTR_SKIP);'."\n";
$output .= '$attributes = \\Livewire\\Blaze\\Runtime\\BlazeAttributeBag::make($__data, $__bound, $__keys);'."\n";
$output .= 'unset($__data, $__bound, $__keys);'."\n";
$output .= 'ob_start();' . "\n";
Expand Down
2 changes: 2 additions & 0 deletions tests/Compiler/WrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'if (($__data[\'attributes\'] ?? null) instanceof \Illuminate\View\ComponentAttributeBag) { $__data = $__data + $__data[\'attributes\']->all(); unset($__data[\'attributes\']); } ',
'extract($__slots, EXTR_SKIP); unset($__slots); ',
'extract($__data, EXTR_SKIP); ',
'extract($__env->getShared(), EXTR_SKIP); ',
'$attributes = \Livewire\Blaze\Runtime\BlazeAttributeBag::make($__data, $__bound, $__keys); ',
'unset($__data, $__bound, $__keys); ',
'ob_start(); ?> ',
Expand All @@ -44,6 +45,7 @@
'if (($__data[\'attributes\'] ?? null) instanceof \Illuminate\View\ComponentAttributeBag) { $__data = $__data + $__data[\'attributes\']->all(); unset($__data[\'attributes\']); } ',
'extract($__slots, EXTR_SKIP); unset($__slots); ',
'extract($__data, EXTR_SKIP); ',
'extract($__env->getShared(), EXTR_SKIP); ',
'$attributes = \Livewire\Blaze\Runtime\BlazeAttributeBag::make($__data, $__bound, $__keys); ',
'unset($__data, $__bound, $__keys); ',
'ob_start(); ?> ',
Expand Down
9 changes: 9 additions & 0 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Illuminate\Contracts\View\Engine;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\View\Component;
use Livewire\Blaze\Blaze;
use Livewire\Blaze\BlazeManager;
Expand Down Expand Up @@ -85,6 +86,14 @@ public function render()
})->assertSee('from-livewire');
});

test('View::share variables are accessible in components', function () {
View::share('sharedValue', 'hello-from-share');

$html = Blade::render('<x-shared-var />');

expect($html)->toContain('hello-from-share');
});

test('folds and compiles the same component', function () {
Blade::render(<<<'BLADE'
<x-foldable.input required /> {{-- Folded --}}
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/views/components/shared-var.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@blaze

<span>{{ $sharedValue }}</span>
Loading