Slice-Library icon indicating copy to clipboard operation
Slice-Library copied to clipboard

yield don't support 2 files having section for that yield

Open jarzebowsky opened this issue 8 years ago • 6 comments

Blade has it resolved and here is article (https://vijayasankarn.wordpress.com/2017/02/03/add-multiple-contents-to-yield-from-section/) what's the problem and how to solve it, can we get that on that library? I'm talking about @push and @stack.

jarzebowsky avatar Mar 22 '18 15:03 jarzebowsky

@Jarzebowsky You can append contents of your section using @section@show placeholder, instead of @yield, for example:

master.slice.php

@section('mySection') //your content here @show

sub.slice.php

@extends('master') @section('mySection') //content to append here @endsection

davideloba avatar Mar 29 '18 07:03 davideloba

@davideloba Is it a proper way to do it?

jarzebowsky avatar Mar 29 '18 07:03 jarzebowsky

@Jarzebowsky for me this works, let me know:

master.slice.php @Section('mySection') //your content here @show

sub.slice.php @extends('master') @include('subOne') @include('subTwo')

subOne.slice.php @Section('mySection') //first content to append here @endsection

subTwo.slice.php @Section('mySection') //second content to append here @endsection

davideloba avatar Mar 29 '18 07:03 davideloba

I know what you are talking about, but thats (https://laravel.com/docs/5.6/blade#stacks) exactly what I'm missing.

jarzebowsky avatar Mar 29 '18 07:03 jarzebowsky

I know blade @stack @push features but as far I can see, Slice doesn't have something like that. For my purposes (appending contents from different subviews) that workaround does what I need.

davideloba avatar Mar 29 '18 07:03 davideloba

What about if I give some1 an ability to create module to my CMS, without giving him access to main view to make him include his section he created?

jarzebowsky avatar Mar 29 '18 07:03 jarzebowsky