Commit 0e4a6360 authored by Taylor Otwell's avatar Taylor Otwell

Added render_each helper.

parent e04b7a3a
...@@ -18,7 +18,6 @@ class Blade { ...@@ -18,7 +18,6 @@ class Blade {
'yields', 'yields',
'section_start', 'section_start',
'section_end', 'section_end',
'render_each',
); );
/** /**
...@@ -239,19 +238,6 @@ class Blade { ...@@ -239,19 +238,6 @@ class Blade {
return preg_replace('/@endsection/', '<?php \\Laravel\\Section::stop(); ?>', $value); return preg_replace('/@endsection/', '<?php \\Laravel\\Section::stop(); ?>', $value);
} }
/**
* Rewrites Blade @render_each statements into View statements.
*
* @param string $value
* @return string
*/
protected static function compile_render_each($value)
{
$pattern = static::matcher('render_each');
return preg_replace($pattern, '$1<?php \\Laravel\\View::render_each$2; ?>', $value);
}
/** /**
* Get the regular expression for a generic Blade function. * Get the regular expression for a generic Blade function.
* *
......
...@@ -436,4 +436,18 @@ function has_php($version) ...@@ -436,4 +436,18 @@ function has_php($version)
function render($view, $data = array()) function render($view, $data = array())
{ {
return Laravel\View::make($view, $data)->render(); return Laravel\View::make($view, $data)->render();
}
/**
* Get the rendered contents of a partial from a loop.
*
* @param string $view
* @param array $data
* @param string $iterator
* @param string $empty
* @return string
*/
function render_each($partial, array $data, $iterator, $empty = 'raw|')
{
return Laravel\View::render_each($partial, $data, $iterator, $empty);
} }
\ No newline at end of file
...@@ -232,7 +232,7 @@ class View implements ArrayAccess { ...@@ -232,7 +232,7 @@ class View implements ArrayAccess {
* @param string $empty * @param string $empty
* @return string * @return string
*/ */
public static function render_each($view, array $data, $iterator, $empty = null) public static function render_each($view, array $data, $iterator, $empty = 'raw|')
{ {
$result = ''; $result = '';
...@@ -260,7 +260,7 @@ class View implements ArrayAccess { ...@@ -260,7 +260,7 @@ class View implements ArrayAccess {
} }
else else
{ {
$result = render($empty ?: $view.'_empty'); $result = render($empty);
} }
} }
......
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