Added support for true tempting.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
Taylor Otwell
2012-03-23 17:03:27 -05:00
parent 8e8b0b8cb3
commit 93e21e9255
3 changed files with 111 additions and 211 deletions

View File

@@ -14,7 +14,7 @@ class Section {
*
* @var array
*/
protected static $last = array();
public static $last = array();
/**
* Start injecting content into a section.
@@ -33,9 +33,14 @@ class Section {
*/
public static function start($section, $content = '')
{
if ($content === '') ob_start() and static::$last[] = $section;
static::append($section, $content);
if ($content === '')
{
ob_start() and static::$last[] = $section;
}
else
{
static::append($section, $content);
}
}
/**
@@ -57,14 +62,26 @@ class Section {
static::start($section, $content);
}
/**
* Stop injecting content into a section and return its contents.
*
* @return string
*/
public static function yield_section()
{
return static::yield(static::stop());
}
/**
* Stop injecting content into a section.
*
* @return void
* @return string
*/
public static function stop()
{
static::append(array_pop(static::$last), ob_get_clean());
static::append($last = array_pop(static::$last), ob_get_clean());
return $last;
}
/**
@@ -78,10 +95,12 @@ class Section {
{
if (isset(static::$sections[$section]))
{
$content = static::$sections[$section].PHP_EOL.$content;
static::$sections[$section] = str_replace('@parent', $content, static::$sections[$section]);
}
else
{
static::$sections[$section] = $content;
}
static::$sections[$section] = $content;
}
/**