From 44dbbe01dae2ed961282a0035c8fd640b5ddd8ab Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 13 Apr 2012 13:54:56 -0500 Subject: [PATCH] added support for bundles outside of the bundle directory using 'path: ' syntax like views. --- laravel/blade.php | 12 ++++++------ laravel/bundle.php | 20 +++++++++++++++----- laravel/documentation/changes.md | 1 + 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/laravel/blade.php b/laravel/blade.php index 3683260e..929efd05 100644 --- a/laravel/blade.php +++ b/laravel/blade.php @@ -118,7 +118,7 @@ class Blade { protected static function compile_layouts($value) { // 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. 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 - // 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); $pattern = static::matcher('layout'); @@ -135,7 +135,7 @@ class Blade { $lines[] = preg_replace($pattern, '$1@include$2', $lines[0]); // 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. return implode(CRLF, array_slice($lines, 1)); } @@ -203,8 +203,8 @@ class Blade { $blade = preg_replace($search, $replace, $forelse); // 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); } diff --git a/laravel/bundle.php b/laravel/bundle.php index dd582138..b6f614e9 100644 --- a/laravel/bundle.php +++ b/laravel/bundle.php @@ -271,9 +271,19 @@ class Bundle { { 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) { // 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])) { return static::$elements[$identifier]; @@ -387,7 +397,7 @@ class 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. - // The "application" folder essentially behaves as a bundle. + // The application folder essentially behaves as a default bundle. else { $element = array(DEFAULT_BUNDLE, strtolower($identifier)); diff --git a/laravel/documentation/changes.md b/laravel/documentation/changes.md index 46eddcdf..de952506 100644 --- a/laravel/documentation/changes.md +++ b/laravel/documentation/changes.md @@ -33,6 +33,7 @@ - [Added `unless` structure to Blade template engine](/docs/views/templating#blade-unless). - [Added Blade comments](/docs/views/templating#blade-comments). - [Added simpler environment management](/docs/install#environments). +- Added support for bundles outside of the bundle directory. - Added support for DateTime database query bindings. - Migrated to the Symfony HttpFoundation component for core request / response handling. - Fixed the passing of strings into the `Input::except` method.