From f0f9d7b25655dd1879db993e1cf82518789f2683 Mon Sep 17 00:00:00 2001 From: Colin Viebrock Date: Fri, 6 Apr 2012 11:50:01 -0500 Subject: [PATCH] make Section::append public, and do a true append. Other methods are renamed but unchanged. --- laravel/section.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/laravel/section.php b/laravel/section.php index ff12889f..cae10717 100644 --- a/laravel/section.php +++ b/laravel/section.php @@ -39,7 +39,7 @@ public static function start($section, $content = '') } else { - static::append($section, $content); + static::extend($section, $content); } } @@ -79,19 +79,20 @@ public static function yield_section() */ public static function stop() { - static::append($last = array_pop(static::$last), ob_get_clean()); + static::extend($last = array_pop(static::$last), ob_get_clean()); return $last; } /** - * Append content to a given section. + * Extend the content in a given section. + * The old content can be injected into the new using "@parent". * * @param string $section * @param string $content * @return void */ - protected static function append($section, $content) + protected static function extend($section, $content) { if (isset(static::$sections[$section])) { @@ -103,6 +104,26 @@ protected static function append($section, $content) } } + /** + * Append content to a given section. + * This concatenates the old content and the new. + * + * @param string $section + * @param string $content + * @return void + */ + public static function append($section, $content) + { + if (isset(static::$sections[$section])) + { + static::$sections[$section] .= $content; + } + else + { + static::$sections[$section] = $content; + } + } + /** * Get the string contents of a section. *