Skip to content

Commit c5e7d08

Browse files
authored
Merge pull request #49 from Clarence-pan/master
Fix bug: when a CRLF is in @widget, blade will complains! It is not s…
2 parents 05dd039 + b6540f8 commit c5e7d08

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/ServiceProvider.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,20 @@ public function boot()
7070
});
7171
}
7272

73-
$this->registerBladeDirective('widget', '$1<?php echo app("arrilot.widget")->run$2; ?>');
73+
Blade::directive('widget', function ($expression) {
74+
return "<?php echo app('arrilot.widget')->run{$expression}; ?>";
75+
});
76+
77+
// Blade::directive cannot recognize @async-widget, so @async-widget still use the custom matcher.
7478
$this->registerBladeDirective('async-widget', '$1<?php echo app("arrilot.async-widget")->run$2; ?>');
75-
$this->registerBladeDirective('asyncWidget', '$1<?php echo app("arrilot.async-widget")->run$2; ?>');
76-
$this->registerBladeDirective('widgetGroup', '$1<?php echo app("arrilot.widget-group-collection")->group$2->display(); ?>');
79+
80+
Blade::directive('asyncWidget', function ($expression) {
81+
return "<?php echo app('arrilot.async-widget')->run{$expression}; ?>";
82+
});
83+
84+
Blade::directive('widgetGroup', function ($expression) {
85+
return "<?php echo app('arrilot.widget-group-collection')->group{$expression}->display(); ?>";
86+
});
7787
}
7888

7989
/**

0 commit comments

Comments
 (0)