Browse Source

Added "shares" method to view instance.

Taylor Otwell 12 years ago
parent
commit
090bf9b3f8
3 changed files with 22 additions and 0 deletions
  1. 3 0
      application/routes.php
  2. 4 0
      application/views/home/index.php
  3. 15 0
      laravel/view.php

+ 3 - 0
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');
 });
 

+ 4 - 0
application/views/home/index.php

@@ -101,6 +101,10 @@
 
 			<h3>Learn the terrain.</h3>
 
+			@forelse ($something as $something)
+				Do Stuff.
+			@endforelse
+
 			<p>
 				You've landed yourself on our default home page. The route that
 				is generating this page lives at:

+ 15 - 0
laravel/view.php

@@ -380,6 +380,21 @@ class View implements ArrayAccess {
 		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.
 	 *