In my attempts to find a way to pass the variable by reference to the @include blade server , I created a simple test case that also demonstrates that the order of the patterns is rather unstable. Is there a way to use clip templates with a variable in which the order of execution takes place (in particular with respect to sections)?
Test case:
testLayout.blade.php
<!DOCTYPE html> <html> <head> </head> <body> {{"this is the layout: ".++$tabindex."<br>"}} @include('testInclude') {{"this is the layout after include: ".++$tabindex."<br>"}} @include('testInclude',array('tabindex'=>$tabindex)) {{"this is the layout after passing include: ".++$tabindex."<br>"}} @yield('testYield') {{"this is the layout after yield: ".++$tabindex."<br>"}} @section('testSection') {{"this is the layout section: ".++$tabindex."<br>"}} @show {{"this is the layout after section: ".++$tabindex."<br>"}} </body> </html>
testExtension.blade.php
@extends('testLayout') {{"this is the extension: ".++$tabindex."<br>"}} @include('testInclude') {{"this is the extension after include: ".++$tabindex."<br>"}} @include('testInclude',array('tabindex'=>$tabindex)) {{"this is the extension after passing include: ".++$tabindex."<br>"}} @section('testYield') {{"this is the extension yield: ".++$tabindex."<br>"}} @stop {{"this is the extension after yield: ".++$tabindex."<br>"}} @section('testSection') {{"this is the extension section: ".++$tabindex."<br>"}} @parent {{"this is the extension section after parent: ".++$tabindex."<br>"}} @stop {{"this is the extension after section: ".++$tabindex."<br>"}}
testInclude.blade.php
{{"this is the include: ".++$tabindex."<br>"}}
routes.php
Route::get('test', function(){ return View::make('testExtension',array('tabindex'=>0)); });
Conclusion:
this is the extension: 1 this is the include: 2 this is the extension after include: 2 this is the include: 3 this is the extension after passing include: 3 this is the extension after yield: 5 this is the extension after section: 8 this is the layout: 9 this is the include: 10 this is the layout after include: 10 this is the include: 11 this is the layout after passing include: 11 this is the extension yield: 4 this is the layout after yield: 12 this is the extension section: 6 this is the layout section: 13 this is the extension section after parent: 7 this is the layout after section: 14
Analysis:
It looks like the values โโare computed in the extension, and then computed in the layout, and then reordered. Since this is another separate issue, please ignore that all instances of @include are value-transmitted and thus do not affect the value in their included files. I, as a rule, are also less concerned about values โโoutside the sections, because the behavior there is understandably less predictable. This is problematic in sections.
If the layout does something with the value, the value will be calculated after all the extension values โโhave been calculated, and this is problematic because the execution order does not explicitly mimic the output order. To make the values โโbehave the way they should, I could @overwrite all the applicable cases in each extension, first defeating the point of using templates, but in this case I would be just as good to define each view without any such extension at all.
Is there a way to make the sections behave in order or can I only use templates for things where the values โโare not order dependent?