Open beeards opened 2 years ago
This seems to bypass it, but it's redundant
{!! Blade::render(Blade::render(" {{ svg('o-home', 'method-X-times-render', ['defer' => true]) }} ")) !!}
This feature was added by @indykoning. Right now, I have no plans on providing support myself for this feature but would appreciate it if either @indykoning could look into this or if someone can send in a PR. Thanks
It seems that any escape/print texts are compiled later in the process thus not triggering the blade engine to actually compile the @once and @push statements to php code.
What this boils down to is that it is not possible to directly print out the defered icons i'm afraid.
Three possible fixes in usage of it are using 1: using the blade component of it
<x-icon-o-home defer/>
2:
{!! Blade::render(svg('o-home', 'method-A', ['defer'])->toHtml()) !!}
As this tells blade to render the html result of the svg function, thus compiling the php code.
3:
not deferring the svg
helper function at all which is the fastest fix.
We cannot tell the helper function to compile the output of the svg class itself as we don't know if it is rendered in blade. Trying to defer would in that case break and deferring wouldn't actually work either. What could be done is extending the blade directive to render what comes out of the svg function https://github.com/blade-ui-kit/blade-icons/blob/1.x/src/BladeIconsServiceProvider.php#L98 as the blade directive can only be used in blade
Gonna revisit this as I want to see this solved. I haven't dug deep into this yet so would appreciate any help here. I'm not sure extending Blade is the right solution.
Library version
v1.3.0
Laravel version
v9.18.0
PHP version
v8.1.7
Description
defer
it's not working as expected with the helper function. I have the components deactivated, but even activated it fails. And the sets enabled too.Steps to reproduce
Method 1
outputs
Method 2
outputs