From 090bf9b3f8b53a911ae0bd3cf424ec3257a9375a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 22 Mar 2012 13:38:22 -0500 Subject: [PATCH] Added "shares" method to view instance. --- application/routes.php | 3 +++ application/views/home/index.php | 4 ++++ laravel/view.php | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/application/routes.php b/application/routes.php index 91d17aa9..a13a171c 100644 --- a/application/routes.php +++ b/application/routes.php @@ -35,6 +35,9 @@ Route::get('/', function() { + $content = file_get_contents(path('app').'views/home/index.php'); + $matches = preg_match('/(\s*)@forelse(\s*\(.*\))(.+)@endforelse/m', $content); + die(var_dump($matches)); return View::make('home.index'); }); diff --git a/application/views/home/index.php b/application/views/home/index.php index 156c36ab..093f8c30 100644 --- a/application/views/home/index.php +++ b/application/views/home/index.php @@ -101,6 +101,10 @@

Learn the terrain.

+ @forelse ($something as $something) + Do Stuff. + @endforelse +

You've landed yourself on our default home page. The route that is generating this page lives at: diff --git a/laravel/view.php b/laravel/view.php index 52cac63e..30e05902 100644 --- a/laravel/view.php +++ b/laravel/view.php @@ -380,6 +380,21 @@ public function with($key, $value) return $this; } + /** + * Add a key / value pair to the shared view data. + * + * Shared view data is accessible to every view created by the application. + * + * @param string $key + * @param mixed $value + * @return View + */ + public function shares($key, $value) + { + static::share($key, $value); + return $this; + } + /** * Add a key / value pair to the shared view data. *