diff --git a/laravel/blade.php b/laravel/blade.php index c5d44c48..3683260e 100644 --- a/laravel/blade.php +++ b/laravel/blade.php @@ -9,6 +9,7 @@ class Blade { */ protected static $compilers = array( 'layouts', + 'comments', 'echos', 'forelse', 'empty', @@ -152,6 +153,19 @@ protected static function extract($value, $expression) return str_replace(array("('", "')"), '', $matches[1]); } + /** + * Rewrites Blade comments into PHP comments. + * + * @param string $value + * @return string + */ + protected static function compile_comments($value) + { + $value = preg_replace('/\{\{--(.+?)(--\}\})?\n/', "", $value); + + return preg_replace('/\{\{--((.|\s)*?)--\}\}/', "\n", $value); + } + /** * Rewrites Blade echo statements into PHP echo statements. * diff --git a/laravel/documentation/changes.md b/laravel/documentation/changes.md index c3fd3751..baad7828 100644 --- a/laravel/documentation/changes.md +++ b/laravel/documentation/changes.md @@ -29,6 +29,7 @@ ## Laravel 3.2 - [Added `sync` method to has\_many\_and\_belongs\_to Eloquent relationship](/docs/database/eloquent#sync-method). - [Added `save` method to has\_many Eloquent relationship](/docs/database/eloquent#has-many-save). - [Added `unless` structure to Blade template engine](/docs/views/templating#blade-unless). +- [Added Blade comments](/docs/views/templating#blade-comments). - Migrated to the Symfony HttpFoundation component for core request / response handling. - Fixed the passing of strings into the `Input::except` method. - Fixed replacement of optional parameters in `URL::transpose` method. diff --git a/laravel/documentation/views/templating.md b/laravel/documentation/views/templating.md index 9cba301c..e88d3792 100644 --- a/laravel/documentation/views/templating.md +++ b/laravel/documentation/views/templating.md @@ -118,6 +118,16 @@ #### The "unless" control structure: ... + +#### Blade comments: + + @if ($check) + {{-- This is a comment --}} + ... + @endif + +> **Note:** Blade comments, unlike HTML comments, are not visible in the HTML source. + ## Blade Layouts