My current build relies heavily on blade components & slots and within some of those there are references to the $page variable which is currently undefined when called inside @component template.
Currently I have to pass the variable every time I use a component.
Component
<!-- /source/_components/sharer.blade.php -->
<div class="container">{{ $slot }}</div>
<ul>
<li>
<a href="https://www.facebook.com/sharer/sharer.php?u={{ urlencode($page->getUrl()) }}">Share on Facebook</a>
</li>
<li>
<a href="https://twitter.com/home?status={{ urlencode($page->getUrl()) }}">Share on Twitter</a>
</li>
</ul>
Usage
<!-- /source/index.blade.php -->
@component('_components.sharer', ['page' => $page])
<p>Some content here</p>
@endcomponent
Would be good if this was accessible without having to pass it as an attribute.
Thanks.
Blade component-related question...
Is it possible to use Blade component aliases in Jigsaw or does it lack the Laravel components that enable this?
Reference:
https://sebastiandedeyne.com/posts/2018/blade-component-aliases-in-laravel-56
@raniesantos Yes it is possible, as of about a week ago, from PR https://github.com/tightenco/jigsaw/pull/204, thought hasn't been documented yet.
Add a blade.php file to your project, which will have access to a $bladeCompiler variable from which you can add component aliases, include aliases, and custom directives. For a component alias:
$bladeCompiler->component('_components.alert');
...would give you an @alert alias.
Most helpful comment
@raniesantos Yes it is possible, as of about a week ago, from PR https://github.com/tightenco/jigsaw/pull/204, thought hasn't been documented yet.
Add a
blade.phpfile to your project, which will have access to a$bladeCompilervariable from which you can add component aliases, include aliases, and custom directives. For a component alias:...would give you an
@alertalias.