Hey all - been diving into Sage 9 and ran into some trouble implementing a Blade feature that would really help streamline my process.
I’ve been building out a modular system with a rigid HTML structure of sections > rows > columns > elements. To keep the markup consistent, I’ve been using @component to pull in some HTML to wrap whatever’s inside it.
For example, a 2-column section might look like:
@component('components.row', ['row_data' => 'something'])
@component('components.column', ['col1_data' => 'col1_something'])
{-- Column 1 stuff --}
@endcomponent
@component('components.column', ['col2_data' => 'col2_something'])
{-- Column 2 stuff --}
@endcomponent
@endcomponent
which generates something like:
<div class="row something">
<div class="column col1_something">
{-- Column 1 stuff --}
</div>
<div class="column col2_something">
{-- Column 2 stuff --}
</div>
</div>
That’s real annoying to keep typing over and over, and starts to get difficult to organize.
As of v5.6, Blade supports aliasing components (https://laravel.com/docs/5.6/blade#components-and-slots), but Blade’s documentation refers to putting code in a file that doesn’t exist in a standard Sage install. I’ve tried a handful of seemingly related techniques from other threads here but haven’t found a method of setting up this feature that works.
According to Blade documentation, I should be able to replace the above code with something like:
@row( ['rowdata' => 'something'] )
@column( ['col1_data' => 'col1_something'] )
{-- Column 1 stuff --}
@endcolumn
@column( ['col2_data' => 'col1_something'] )
{-- Column 2 stuff --}
@endcolumn
@endrow
…which is much easier to read/understand. Unfortunately, I haven’t been able to figure out how to get Blade component aliasing to work in Sage’s structure.
Has anyone been able to get this kind of aliasing to work?