Added render_each helper.
This commit is contained in:
parent
e04b7a3add
commit
0e4a63606f
|
@ -18,7 +18,6 @@ class Blade {
|
||||||
'yields',
|
'yields',
|
||||||
'section_start',
|
'section_start',
|
||||||
'section_end',
|
'section_end',
|
||||||
'render_each',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -239,19 +238,6 @@ protected static function compile_section_end($value)
|
||||||
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)
|
||||||
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);
|
||||||
}
|
}
|
|
@ -232,7 +232,7 @@ public static function composer($view, $composer)
|
||||||
* @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 @@ public static function render_each($view, array $data, $iterator, $empty = null)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result = render($empty ?: $view.'_empty');
|
$result = render($empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue