Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
727b064b
Commit
727b064b
authored
Mar 22, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added View::render_each and Blade shortcut.
parent
9df88c46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
31 deletions
+50
-31
blade.php
laravel/blade.php
+14
-0
view.php
laravel/view.php
+36
-31
No files found.
laravel/blade.php
View file @
727b064b
...
...
@@ -18,6 +18,7 @@ class Blade {
'yields'
,
'section_start'
,
'section_end'
,
'render_each'
,
);
/**
...
...
@@ -238,6 +239,19 @@ class Blade {
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.
*
...
...
laravel/view.php
View file @
727b064b
...
...
@@ -37,20 +37,6 @@ class View implements ArrayAccess {
*/
public
static
$names
=
array
();
/**
* The extensions a view file can have.
*
* @var array
*/
public
static
$extensions
=
array
(
EXT
);
/**
* The path in which a view can live.
*
* @var array
*/
public
static
$paths
=
array
(
DEFAULT_BUNDLE
=>
array
(
''
));
/**
* The Laravel view loader event name.
*
...
...
@@ -238,28 +224,47 @@ class View implements ArrayAccess {
}
/**
*
Register a new root path for a bundle
.
*
Get the rendered contents of a partial from a loop
.
*
* @param string $bundle
* @param string $path
* @return void
* @param string $view
* @param array $data
* @param string $iterator
* @param string $empty
* @return string
*/
public
static
function
search
(
$bundle
,
$path
)
public
static
function
render_each
(
$view
,
array
$data
,
$iterator
,
$empty
=
null
)
{
static
::
$paths
[
$bundle
][]
=
$path
;
}
$result
=
''
;
/**
* Register a new valid view extension.
*
* @param string $extension
* @return void
*/
public
static
function
extension
(
$extension
)
{
static
::
$extensions
[]
=
$extension
;
// If is actually data in the array, we will loop through the data and
// append an instance of the partial view to the final result HTML,
// passing in the iterated value of the data array.
if
(
count
(
$data
)
>
0
)
{
foreach
(
$data
as
$key
=>
$value
)
{
$with
=
array
(
'key'
=>
$key
,
$iterator
=>
$value
);
$result
.=
render
(
$view
,
$with
);
}
}
// If there is no data in the array, we will render the contents of
// the "empty" view. Alternative, the "empty view" can be a raw
// string that is prefixed with "raw|" for convenience.
else
{
if
(
starts_with
(
$empty
,
'raw|'
))
{
$result
=
substr
(
$empty
,
4
);
}
else
{
$result
=
render
(
$empty
?:
$view
.
'_empty'
);
}
}
static
::
$extensions
=
array_unique
(
static
::
$extensions
)
;
return
$result
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment