added unless structure to blade.
This commit is contained in:
parent
fda19731c5
commit
f7b1a72f3c
|
@ -16,6 +16,8 @@ class Blade {
|
|||
'structure_openings',
|
||||
'structure_closings',
|
||||
'else',
|
||||
'unless',
|
||||
'endunless',
|
||||
'includes',
|
||||
'render_each',
|
||||
'render',
|
||||
|
@ -254,6 +256,30 @@ protected static function compile_else($value)
|
|||
return preg_replace('/(\s*)@(else)(\s*)/', '$1<?php $2: ?>$3', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrites Blade "unless" statements into valid PHP.
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected static function compile_unless($value)
|
||||
{
|
||||
$pattern = '/(\s*)@unless(\s*\(.*\))/';
|
||||
|
||||
return preg_replace($pattern, '$1<?php if( ! ($2)): ?>', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrites Blade "unless" endings into valid PHP.
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected static function compile_endunless($value)
|
||||
{
|
||||
return str_replace('@endunless', '<?php endif; ?>', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrites Blade @include statements into valid PHP.
|
||||
*
|
||||
|
|
|
@ -28,6 +28,7 @@ ## Laravel 3.2
|
|||
- [Added `$hidden` static variable to the base Eloquent model](/docs/database/eloquent#to-array).
|
||||
- [Added `sync` method to has\_many\_and\_belongs\_to Eloquent relationship](/docs/database/eloquent#sync-method).
|
||||
- [Added `save` method to has\_many Eloquent relationship](/docs/database/eloquent#has-many-save).
|
||||
- [Added `unless` structure to Blade template engine](/docs/views/templating#blade-unless).
|
||||
- Migrated to the Symfony HttpFoundation component for core request / response handling.
|
||||
- Fixed the passing of strings into the Input::except method.
|
||||
- Fixed replacement of optional parameters in URL::transpose method.
|
||||
|
|
|
@ -105,6 +105,19 @@ #### The "for-else" control structure:
|
|||
There are not posts in the array!
|
||||
@endforelse
|
||||
|
||||
<a name="blade-unless"></a>
|
||||
#### The "unless" control structure:
|
||||
|
||||
@unless(Auth::check())
|
||||
{{ HTML::link_to_route('login', 'Login'); }}
|
||||
@endunless
|
||||
|
||||
// Equivalent...
|
||||
|
||||
<?php if ( ! Auth::check()): ?>
|
||||
...
|
||||
<?php endif; ?>
|
||||
|
||||
<a name="blade-layouts"></a>
|
||||
## Blade Layouts
|
||||
|
||||
|
|
Loading…
Reference in New Issue