From 49d3c5251b5c81195e0460ae24e0d7165a703728 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 23 Feb 2012 22:34:42 -0600 Subject: [PATCH] removed blade from core and extracted it into bundle. added view engine event to hook in any view engine to the core. --- laravel/blade.php | 151 --------------------------------------- laravel/view.php | 17 +++-- storage/views/.gitignore | 2 - 3 files changed, 13 insertions(+), 157 deletions(-) delete mode 100644 laravel/blade.php delete mode 100644 storage/views/.gitignore diff --git a/laravel/blade.php b/laravel/blade.php deleted file mode 100644 index 535e2736..00000000 --- a/laravel/blade.php +++ /dev/null @@ -1,151 +0,0 @@ -', $value); - } - - /** - * Rewrites Blade structure openings into PHP structure openings. - * - * @param string $value - * @return string - */ - protected static function compile_structure_openings($value) - { - $pattern = '/(\s*)@(if|elseif|foreach|for|while)(\s*\(.*\))/'; - - return preg_replace($pattern, '$1', $value); - } - - /** - * Rewrites Blade structure closings into PHP structure closings. - * - * @param string $value - * @return string - */ - protected static function compile_structure_closings($value) - { - $pattern = '/(\s*)@(endif|endforeach|endfor|endwhile)(\s*)/'; - - return preg_replace($pattern, '$1$3', $value); - } - - /** - * Rewrites Blade else statements into PHP else statements. - * - * @param string $value - * @return string - */ - protected static function compile_else($value) - { - return preg_replace('/(\s*)@(else)(\s*)/', '$1$3', $value); - } - - /** - * Rewrites Blade @yield statements into Section statements. - * - * The Blade @yield statement is a shortcut to the Section::yield method. - * - * @param string $value - * @return string - */ - protected static function compile_yields($value) - { - $pattern = static::matcher('yield'); - - return preg_replace($pattern, '$1', $value); - } - - /** - * Rewrites Blade @section statements into Section statements. - * - * The Blade @section statement is a shortcut to the Section::start method. - * - * @param string $value - * @return string - */ - protected static function compile_section_start($value) - { - $pattern = static::matcher('section'); - - return preg_replace($pattern, '$1', $value); - } - - /** - * Rewrites Blade @endsection statements into Section statements. - * - * The Blade @endsection statement is a shortcut to the Section::stop method. - * - * @param string $value - * @return string - */ - protected static function compile_section_end($value) - { - return preg_replace('/@endsection/', '', $value); - } - - /** - * Get the regular expression for a generic Blade function. - * - * @param string $function - * @return string - */ - protected static function matcher($function) - { - return '/(\s*)@'.$function.'(\s*\(.*\))/'; - } - -} \ No newline at end of file diff --git a/laravel/view.php b/laravel/view.php index fd2e56a8..dc1b5209 100644 --- a/laravel/view.php +++ b/laravel/view.php @@ -37,6 +37,13 @@ class View implements ArrayAccess { */ public static $names = array(); + /** + * The Laravel view engine event name. + * + * @var string + */ + const engine = 'laravel.view.engine'; + /** * Create a new view instance. * @@ -194,15 +201,17 @@ public function render() { // To allow bundles or other pieces of the application to modify the // view before it is rendered, we'll fire an event, passing in the - // view instance so it can modified. - Event::fire("laravel.composing: {$this->view}", array($this)); + // view instance so it can modified by the composer. + $composer = "laravel.composing: {$this->view}"; + + Event::fire($composer, array($this)); // If there are listeners to the view engine event, we'll pass them // the view so they can render it according to their needs, which // allows easy attachment of other view parsers. - if (Event::listeners('laravel.viewer')) + if (Event::listeners(static::engine)) { - return Event::first('laravel.viewer', array($this)); + return Event::first(static::engine, array($this)); } else { diff --git a/storage/views/.gitignore b/storage/views/.gitignore deleted file mode 100644 index c96a04f0..00000000 --- a/storage/views/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file