8000 Merge branch 'staging' · laravel/laravel@928ce7c · GitHub
[go: up one dir, main page]

Skip to content

Commit 928ce7c

Browse files
committed
Merge branch 'staging'
2 parents dd01308 + 9b90242 commit 928ce7c

File tree

11 files changed

+307
-119
lines changed

11 files changed

+307
-119
lines changed

application/config/application.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@
9494

9595
'language' => 'en',
9696

97+
/*
98+
|--------------------------------------------------------------------------
99+
| Supported Languages
100+
|--------------------------------------------------------------------------
101+
|
102+
| These languages may also be supported by your application. If a request
103+
| enters your application with a URI beginning with one of these values
104+
| the default language will automatically be set to that language.
105+
|
106+
*/
107+
108+
'languages' => array(),
109+
97110
/*
98111
|--------------------------------------------------------------------------
99112
| SSL Link Generation

artisan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Laravel - A PHP Framework For Web Artisans
55
*
66
* @package Laravel
7-
* @version 3.2.5
7+
* @version 3.2.6
88
* @author Taylor Otwell <taylorotwell@gmail.com>
99
* @link http://laravel.com
1010
*/

laravel/blade.php

Lines changed: 52 additions & 80 deletions
306
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function expired($view, $path)
105105
/**
106106
* Compiles the specified file containing Blade pseudo-code into valid PHP.
107107
*
108-
* @param string $view
108+
* @param string $path
109109
* @return string
110110
*/
111111
public static function compile($view)
@@ -149,33 +149,31 @@ protected static function compile_layouts($value)
149149
}
150150

151151
// First we'll split out the lines of the template so we can get the
152-
// layout from the top of the template. By convention, it must be
152+
// layout from the top of the template. By convention it must be
153153
// located on the first line of the template contents.
154-
preg_replace_callback(
155-
'/^@layout(\s*?\(.+?\))(\r?\n)?/',
156-
function($matches) use (&$value)
157-
{
158-
$value = substr( $value, strlen( $matches[0] ) ).CRLF.'@include'.$matches[1];
159-
},
160-
$value
161-
);
154+
$lines = preg_split("/(\r?\n)/", $value);
162155

163-
return $value;
156+
$pattern = static::matcher('layout');
157+
158+
$lines[] = preg_replace($pattern, '$1@include$2', $lines[0]);
159+
160+
// We will add a "render" statement to the end of the templates and
161+
// then slice off the "@layout" shortcut from the start so the
162+
// sections register before the parent template renders.
163+
return implode(CRLF, array_slice($lines, 1));
164164
}
165165

166166
/**
167167
* Extract a variable value out of a Blade expression.
168168
*
169169
* @param string $value
170-
* @param string $expression
171170
* @return string
172171
*/
173172
protected static function extract($value, $expression)
174173
{
175-
if ( preg_match("/@layout\s*?\(\s*?'(.+?)'\s*?\)/", $value, $matches))
176-
{
177-
return trim( $matches[1] );
178-
}
174+
preg_match('/@layout(\s*\(.*\))(\s*)/', $value, $matches);
175+
176+
return str_replace(array("('", "')"), '', $matches[1]);
179177
}
180178

181179
/**
@@ -186,9 +184,9 @@ protected static function extract($value, $expression)
186184
*/
187185
protected static function compile_comments($value)
188186
{
189-
$value = preg_replace('/\{\{--(.*?)--\}\}/', "<?php // $1 ?>", $value);
190-
191-
return preg_replace('/\{\{--(.*?)--\}\}/s', "<?php /* ?>$1<?php */ ?>", $value);
187+
$value = preg_replace('/\{\{--(.+?)(--\}\})?\n/', "<?php // $1 ?>", $value);
188+
189+
return preg_replace('/\{\{--((.|\s)*?)--\}\}/', "<?php /* $1 */ ?>\n", $value);
192190
}
193191

194192
/**
@@ -199,7 +197,7 @@ protected static function compile_comments($value)
199197
*/
200198
protected static function compile_echos($value)
201199
{
202-
return preg_replace('/\{\{(.+?)\}\}/s', '<?php echo $1; ?>', $value);
200+
return preg_replace('/\{\{(.+?)\}\}/', '<?php echo $1; ?>', $value);
203201
}
204202

205203
/**
@@ -210,21 +208,27 @@ protected static function compile_echos($value)
210208
*/
211209
protected static function compile_forelse($value)
212210
{
213-
preg_match_all('/@forelse\s*?\(\s*?\$(.+?)\s*?as\s*?\$(.+?)\s*?\)/', $value, $matches, PREG_SET_ORDER );
214-
215-
if ( count($matches) < 1 ) return $value;
211+
preg_match_all('/(\s*)@forelse(\s*\(.*\))(\s*)/', $value, $matches);
216212

217-
foreach ($matches as $forelse)
213+
foreach ($matches[0] as $forelse)
218214
{
215+
preg_match('/\s*\(\s*(\S*)\s/', $forelse, $variable);
216+
219217
// Once we have extracted the variable being looped against, we can add
220218
// an if statement to the start of the loop that checks if the count
221219
// of the variable being looped against is greater than zero.
222-
$replace = '<?php if (count($'.$forelse[1].') > 0): foreach ($'.$forelse[1].' as $'.$forelse[2].'): ?>';
220+
$if = "<?php if (count({$variable[1]}) > 0): ?>";
221+
222+
$search = '/(\s*)@forelse(\s*\(.*\))/';
223+
224+
$replace = '$1'.$if.'<?php foreach$2: ?>';
225+
226+
$blade = preg_replace($search, $replace, $forelse);
223227

224228
// Finally, once we have the check prepended to the loop we'll replace
225229
// all instances of this forelse syntax in the view content of the
226230
// view being compiled to Blade syntax with real PHP syntax.
227-
$value = str_replace($forelse[0], $replace, $value);
231+
$value = str_replace($forelse, $blade, $value);
228232
}
229233

230234
return $value;
@@ -238,7 +242,7 @@ protected static function compile_forelse($value)
238242
*/
239243
protected static function compile_empty($value)
240244
{
241-
return str_replace('@empty', '<?php endforeach; else: ?>', $value);
245+
return str_replace('@empty', '<?php endforeach; ?><?php else: ?>', $value);
242246
}
243247

244248
/**
@@ -260,42 +264,9 @@ protected static function compile_endforelse($value)
260264
*/
261265
protected static function compile_structure_openings($value)
262266
{
263-
preg_replace_callback(
264-
'/@(if|elseif|foreach|for|while)(\s*?)(\([^\n\r\t]+\))/',
265-
function($matches) use (&$value)
266-
{
267-
if(count( $matches ) === 4)
268-
{
269-
$open = 0;
270-
$close = 0;
271-
$cut = 0;
272-
$len = strlen($matches[3]);
273-
for($i = 0; $i < $len; $i++)
274-
{
275-
if($matches[3][$i] === '(' )
276-
{
277-
$open++;
278-
}
279-
if($matches[3][$i] === ')' )
280-
{
281-
$close++;
282-
}
283-
if($open !== 0 && ($open === $close))
284-
{
285-
break;
286-
}
287-
}
288-
$condition = substr($matches[3], 0, ($i + 1));
289-
$value = str_replace(
290-
'@'.$matches[1].$matches[2].$condition,
291-
'<?php '.$matches[1].$condition.': ?>',
292-
$value
293-
);
294-
}
295-
},
296-
$value
297-
);
298-
return $value;
267+
$pattern = '/(\s*)@(if|elseif|foreach|for|while)(\s*\(.*\))/';
268+
269+
return preg_replace($pattern, '$1<?php $2$3: ?>', $value);
299270
}
300271

301272
/**
@@ -306,9 +277,9 @@ function($matches) use (&$value)
277
*/
307278
protected static function compile_structure_closings($value)
308279
{
309-
$pattern = '/@(endif|endforeach|endfor|endwhile|break|continue)/';
280+
$pattern = '/(\s*)@(endif|endforeach|endfor|endwhile)(\s*)/';
310281

311-
return preg_replace($pattern, '<?php $1; ?>', $value);
282+
return preg_replace($pattern, '$1<?php $2; ?>$3', $value);
312283
}
313284

314285
/**
@@ -319,7 +290,7 @@ protected static function compile_structure_closings($value)
319290
*/
320291
protected static function compile_else($value)
321292
{
322-
return str_replace( '@else', '<?php else: ?>', $value);
293+
return preg_replace('/(\s*)@(else)(\s*)/', '$1<?php $2: ?>$3', $value);
323294
}
324295

325296
/**
@@ -330,9 +301,9 @@ protected static function compile_else($value)
330301
*/
331302
protected static function compile_unless($value)
332303
{
333-
$pattern = static::matcher('unless');
304+
$pattern = '/(\s*)@unless(\s*\(.*\))/';
334305

335-
return preg_replace($pattern, '<?php if( ! ($1)): ?>', $value);
306+
return preg_replace($pattern, '$1<?php if( ! ($2)): ?>', $value);
336307
}
337308

338309
/**
@@ -356,7 +327,7 @@ protected static function compile_includes($value)
356327
{
357328
$pattern = static::matcher('include');
358329

359-
return preg_replace($pattern, '<?php echo view$1->with(get_defined_vars())->render(); ?>', $value);
330+
return preg_replace($pattern, '$1<?php echo view$2->with(get_defined_vars())->render(); ?>', $value);
360331
}
361332

362333
/**
@@ -369,7 +340,7 @@ protected static function compile_render($value)
369340
{
370341
$pattern = static::matcher('render');
371342

372-
return preg_replace($pattern, '<?php echo render$1; ?>', $value);
343+
return preg_replace($pattern, '$1<?php echo render$2; ?>', $value);
373344
}
374345

375346
/**
@@ -382,7 +353,7 @@ protected static function compile_render_each($value)
382353
{
383354
$pattern = static::matcher('render_each');
384355

385-
return preg_replace($pattern, '<?php echo render_each$1; ?>', $value);
356+
return preg_replace($pattern, '$1<?php echo render_each$2; ?>', $value);
386357
}
387358

388359
/**
@@ -397,18 +368,19 @@ protected static function compile_yields($value)
397368
{
398369
$pattern = static::matcher('yield');
399370

400-
return preg_replace($pattern, '<?php echo \\Laravel\\Section::yield$1; ?>', $value);
371+
return preg_replace($pattern, '$1<?php echo \\Laravel\\Section::yield$2; ?>', $value);
401372
}
402373

403374
/**
404375
* Rewrites Blade yield section statements into valid PHP.
405376
*
406-
* @param string $value
407377
* @return string
408378
*/
409379
protected static function compile_yield_sections($value)
410380
{
411-
return str_replace('@yield_section', '<?php echo \\Laravel\\Section::yield_section(); ?>', $value);
381+
$replace = '<?php echo \\Laravel\\Section::yield_section(); ?>';
382+
383+
return str_replace('@yield_section', $replace, $value);
412384
}
413385

414386
/**
@@ -423,7 +395,7 @@ protected static function compile_section_start($value)
423395
{
424396
$pattern = static::matcher('section');
425397

426-
return preg_replace($pattern, '<?php \\Laravel\\Section::start$1; ?>', $value);
398+
return preg_replace($pattern, '$1<?php \\Laravel\\Section::start$2; ?>', $value);
427399
}
428400

429401
/**
@@ -436,7 +408,7 @@ protected static function compile_section_start($value)
436408
*/
437409
protected static function compile_section_end($value)
438410
{
439-
return str_replace('@endsection', '<?php \\Laravel\\Section::stop(); ?>', $value);
411+
return preg_replace('/@endsection/', '<?php \\Laravel\\Section::stop(); ?>', $value);
440412
}
441413

442414
/**
@@ -453,7 +425,7 @@ protected static function compile_extensions($value)
453425
}
454426

455427
return $value;
456-
}
428+
}
457429

458430
/**
459431
* Get the regular expression for a generic Blade function.
@@ -463,18 +435,18 @@ protected static function compile_extensions($value)
463435
*/
464436
public static function matcher($function)
465437
{
466-
return '/@'.$function.'\s*?(\(.+?\))/';
438+
return '/(\s*)@'.$function.'(\s*\(.*\))/';
467439
}
468440

469441
/**
470442
* Get the fully qualified path for a compiled view.
471443
*
472-
* @param string $path
444+
* @param string $view
473445
* @return string
474446
*/
475447
public static function compiled($path)
476448
{
477449
return path('storage').'views/'.md5($path);
478450
}
479451

480-
}
452+
}

0 commit comments

Comments
 (0)
0