flatten icon indicating copy to clipboard operation
flatten copied to clipboard

Pass view arguments to the internal function of cache section

Open Namek opened this issue 8 years ago • 2 comments

(copied from #29)

For such case in Laravel when we create view with arguments, such us:

View::make('layouts.index')->with('categories', $categories)

have defined layouts/index.blade.php like this:

<html><body>
    <h1>My page title</h1>
    @include('partials.menu')
    <section id="page-content> ... </section>
</body></html>

and want to use $categories in menu partial:

@cache('menu', 10)
<ul>
@foreach ($categories as $category)
    <li>{{ $category['name'] }}</li>
@endforeach
</ul>
@endcache

the index view didn't pass it's arguments to the menu partial so the commit fixes it. Not sure if it's the best way but it sure works for me.

Namek avatar Sep 10 '15 19:09 Namek

Looks good! Smart way to solve this. Can you add a quick test for this in the TemplatingTest class? With and without arguments passed to section

Anahkiasen avatar Sep 10 '15 20:09 Anahkiasen

I'm not sure how would you like to look like that test, so please do it yourself.

Namek avatar Sep 12 '15 18:09 Namek