Commit 93e21e92 authored by Taylor Otwell's avatar Taylor Otwell

Added support for true tempting.

Signed-off-by: 's avatarTaylor Otwell <taylorotwell@gmail.com>
parent 8e8b0b8c
This diff is collapsed.
......@@ -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;
}
/**
......
......@@ -349,11 +349,11 @@ class View implements ArrayAccess {
// All nested views and responses are evaluated before the main view.
// This allows the assets used by nested views to be added to the
// asset container before the main view is evaluated.
foreach ($data as &$value)
foreach ($data as $key => $value)
{
if ($value instanceof View or $value instanceof Response)
{
$value = $value->render();
$data[$key] = $value->render();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment