Browse Source

added support for bundles outside of the bundle directory using 'path: ' syntax like views.

Taylor Otwell 12 years ago
parent
commit
44dbbe01da
3 changed files with 22 additions and 11 deletions
  1. 6 6
      laravel/blade.php
  2. 15 5
      laravel/bundle.php
  3. 1 0
      laravel/documentation/changes.md

+ 6 - 6
laravel/blade.php

@@ -118,7 +118,7 @@ class Blade {
 	protected static function compile_layouts($value)
 	protected static function compile_layouts($value)
 	{
 	{
 		// If the Blade template is not using "layouts", we'll just return it
 		// If the Blade template is not using "layouts", we'll just return it
-		// it unchanged since there is nothing to do with layouts and we'll
+		// unchanged since there is nothing to do with layouts and we will
 		// just let the other Blade compilers handle the rest.
 		// just let the other Blade compilers handle the rest.
 		if ( ! starts_with($value, '@layout'))
 		if ( ! starts_with($value, '@layout'))
 		{
 		{
@@ -126,8 +126,8 @@ class Blade {
 		}
 		}
 
 
 		// First we'll split out the lines of the template so we can get the
 		// First we'll split out the lines of the template so we can get the
-		// the layout from the top of the template. By convention it must
-		// be located on the first line of the template contents.
+		// layout from the top of the template. By convention it must be
+		// located on the first line of the template contents.
 		$lines = preg_split("/(\r?\n)/", $value);
 		$lines = preg_split("/(\r?\n)/", $value);
 
 
 		$pattern = static::matcher('layout');
 		$pattern = static::matcher('layout');
@@ -135,7 +135,7 @@ class Blade {
 		$lines[] = preg_replace($pattern, '$1@include$2', $lines[0]);
 		$lines[] = preg_replace($pattern, '$1@include$2', $lines[0]);
 
 
 		// We will add a "render" statement to the end of the templates and
 		// We will add a "render" statement to the end of the templates and
-		// and then slice off the @layout shortcut from the start so the
+		// then slice off the "@layout" shortcut from the start so the
 		// sections register before the parent template renders.
 		// sections register before the parent template renders.
 		return implode(CRLF, array_slice($lines, 1));
 		return implode(CRLF, array_slice($lines, 1));
 	}
 	}
@@ -203,8 +203,8 @@ class Blade {
 			$blade = preg_replace($search, $replace, $forelse);
 			$blade = preg_replace($search, $replace, $forelse);
 
 
 			// Finally, once we have the check prepended to the loop we'll replace
 			// Finally, once we have the check prepended to the loop we'll replace
-			// all instances of this "forelse" syntax in the view content of the
-			// view being compiled to Blade syntax with real syntax.
+			// all instances of this forelse syntax in the view content of the
+			// view being compiled to Blade syntax with real PHP syntax.
 			$value = str_replace($forelse, $blade, $value);
 			$value = str_replace($forelse, $blade, $value);
 		}
 		}
 
 

+ 15 - 5
laravel/bundle.php

@@ -271,9 +271,19 @@ class Bundle {
 		{
 		{
 			return path('app');
 			return path('app');
 		}
 		}
-		else if ($location = array_get(static::$bundles, $bundle.'.location'))
+		elseif ($location = array_get(static::$bundles, $bundle.'.location'))
 		{
 		{
-			return str_finish(path('bundle').$location, DS);
+			// If the bundle location starts with "path: ", we will assume that a raw
+			// path has been specified and will simply return it. Otherwise, we'll
+			// prepend the bundle directory path onto the location and return.
+			if (starts_with($location, 'path: '))
+			{
+				return str_finish(substr($location, 6), DS);
+			}
+			else
+			{
+				return str_finish(path('bundle').$location, DS);
+			}
 		}
 		}
 	}
 	}
 
 
@@ -374,8 +384,8 @@ class Bundle {
 	public static function parse($identifier)
 	public static function parse($identifier)
 	{
 	{
 		// The parsed elements are cached so we don't have to reparse them on each
 		// The parsed elements are cached so we don't have to reparse them on each
-		// subsequent request for the parsed element. So, if we've already parsed
-		// the given element, we'll just return the cached copy.
+		// subsequent request for the parsed element. So if we've already parsed
+		// the given element, we'll just return the cached copy as the value.
 		if (isset(static::$elements[$identifier]))
 		if (isset(static::$elements[$identifier]))
 		{
 		{
 			return static::$elements[$identifier];
 			return static::$elements[$identifier];
@@ -387,7 +397,7 @@ class Bundle {
 		}
 		}
 		// If no bundle is in the identifier, we will insert the default bundle
 		// If no bundle is in the identifier, we will insert the default bundle
 		// since classes like Config and Lang organize their items by bundle.
 		// since classes like Config and Lang organize their items by bundle.
-		// The "application" folder essentially behaves as a bundle.
+		// The application folder essentially behaves as a default bundle.
 		else
 		else
 		{
 		{
 			$element = array(DEFAULT_BUNDLE, strtolower($identifier));
 			$element = array(DEFAULT_BUNDLE, strtolower($identifier));

+ 1 - 0
laravel/documentation/changes.md

@@ -33,6 +33,7 @@
 - [Added `unless` structure to Blade template engine](/docs/views/templating#blade-unless).
 - [Added `unless` structure to Blade template engine](/docs/views/templating#blade-unless).
 - [Added Blade comments](/docs/views/templating#blade-comments).
 - [Added Blade comments](/docs/views/templating#blade-comments).
 - [Added simpler environment management](/docs/install#environments).
 - [Added simpler environment management](/docs/install#environments).
+- Added support for bundles outside of the bundle directory.
 - Added support for DateTime database query bindings.
 - Added support for DateTime database query bindings.
 - Migrated to the Symfony HttpFoundation component for core request / response handling.
 - Migrated to the Symfony HttpFoundation component for core request / response handling.
 - Fixed the passing of strings into the `Input::except` method.
 - Fixed the passing of strings into the `Input::except` method.