In setting up Laravel 4.2, I have a variable in the template that I want to share a few words with:
master.blade
<?php $tabindex = 0; ?>{{--This is the variable--}} @include('header'){{-- <-in header.blade, I often use ++$tabindex --}} {{--$tabindex is still 0--}} @include('content'){{-- <-in content.blade, I often use ++$tabindex --}} {{--$tabindex is still 0--}} @include('footer'){{-- <-in footer.blade, I often use ++$tabindex --}} {{--$tabindex is still 0--}}
$tabindex , if used as the tabindex html attribute, is obviously a trivial example of how I can get around safe values ββand a reasonably large buffer value, but this is hardly elegant or a solution to the real problem. It includes regular php , I understand that assigning a variable in the included files will affect the variables in the included file - this is the desired effect.
I tried View::share() , but it presented the same symptoms. Passing a value to @include as an array explicitly passes by value and gives the same effect.
It seems that all values ββof the scope are first evaluated in their entirety, and then included by areas. If so, it would do what I am trying to make much less doable if there is any use in the inclusion area or additional included areas (even for storage through some persistent memory), because the order of execution will be different than the order in the code .
Is there an undocumented witchcraft blades so that the @include blade @include not cut itself off from changing the values ββof its inclusion variables, or should I go back to direct php include or some other ugly alternative ( Session variables should keep their values ββin all calling areas, but this just a nasty and far-fetched approach)?
source share