Ternary in Laravel Blade
问题 Looking for a ternary operator for blade templates @if(Auth::check()) ? yes : no @endif Can't seem to get it to work this works @if(Auth::check()) yes @else no @endif suppose there is not much in it for this example, just curious. 回答1: You are free to use it with {{ }} . {{ Auth::check() ? 'yes' : 'no' }} 回答2: This works: {{ Auth::check() ? 'yes' : 'no' }} 回答3: I know this question was asked a while ago, but this may help somebody. You can now do this in Laravel 5. {{ $variable or "default" }