0
0
Laravelframework~5 mins

Blade template syntax in Laravel - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is Blade in Laravel?
Blade is Laravel's simple, yet powerful templating engine that helps you write HTML templates with embedded PHP code using clean and readable syntax.
Click to reveal answer
beginner
How do you output a variable safely in Blade?
Use double curly braces like {{ $variable }}. This escapes HTML to prevent security issues like XSS.
Click to reveal answer
beginner
How do you write an if-else condition in Blade?
Use directives: @if(condition) ... @elseif(condition) ... @else ... @endif.
Click to reveal answer
beginner
What Blade directive is used to loop over an array or collection?
Use @foreach($items as $item) ... @endforeach to loop through each item.
Click to reveal answer
beginner
How do you include one Blade template inside another?
Use the @include('view.name') directive to insert one template inside another for reusability.
Click to reveal answer
Which Blade syntax outputs a variable with HTML escaped?
A<% $variable %>
B{!! $variable !!}
C@php echo $variable; @endphp
D{{ $variable }}
How do you start a Blade loop over a list called $users?
A@for($users as $user)
B@loop($users)
C@foreach($users as $user)
D@while($users)
Which directive ends an if statement in Blade?
A@closeif
B@endif
C@end
D@endcondition
How do you include a Blade template named 'header'?
A@include('header')
B@insert('header')
C@import('header')
D@embed('header')
What does {!! $variable !!} do in Blade?
AOutputs raw HTML without escaping
BEscapes HTML and outputs safely
CComments out the variable
DThrows an error
Explain how to write conditional statements in Blade templates.
Think about how you check conditions in normal PHP but with Blade directives.
You got /4 concepts.
    Describe how to safely display user input in a Blade template and why it matters.
    Consider what happens if user input contains HTML or scripts.
    You got /4 concepts.