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,10 +33,15 @@ class Section {
*/
public static function start($section, $content = '')
{
if ($content === '') ob_start() and static::$last[] = $section;
if ($content === '')
{
ob_start() and static::$last[] = $section;
}
else
{
static::append($section, $content);
}
}
/**
* Inject inline content into a section.
......@@ -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,11 +95,13 @@ 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;
}
}
/**
* Get the string contents of a section.
......
......@@ -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