0
0
Laravelframework~10 mins

Blade template syntax in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to display a variable in Blade template.

Laravel
<p>[1]</p>
Drag options to blanks, or click blank then click option'
A$name
B{{ $name }}
C@name
Decho $name
Attempts:
3 left
💡 Hint
Common Mistakes
Including the curly braces inside the blank.
Using PHP echo syntax inside Blade.
2fill in blank
medium

Complete the code to write an if statement in Blade.

Laravel
@if([1])
  <p>Welcome back!</p>
@endif
Drag options to blanks, or click blank then click option'
Auser
B$user
C$user == true
Duser == true
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the $ sign before variable.
Writing just the variable name without comparison.
3fill in blank
hard

Fix the error in the Blade loop syntax.

Laravel
@foreach($items as [1])
  <li>{{ $item }}</li>
@endforeach
Drag options to blanks, or click blank then click option'
A$item
Bitem
Citems
Di
Attempts:
3 left
💡 Hint
Common Mistakes
Adding $ before the loop variable in the foreach statement.
Using the collection name instead of the item variable.
4fill in blank
hard

Fill both blanks to create a Blade component with a slot and a variable.

Laravel
<x-alert type=[1]>
  [2]
</x-alert>
Drag options to blanks, or click blank then click option'
A"error"
B{{ $message }}
C$message
D"success"
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the string attribute value.
Using $message without curly braces.
5fill in blank
hard

Fill all three blanks to write a Blade directive for a loop with a condition.

Laravel
@foreach($users as [1])
  @if([2]->active)
    <p>[3]->name</p>
  @endif
@endforeach
Drag options to blanks, or click blank then click option'
Auser
B$user
D$users
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ in the foreach variable.
Omitting $ inside Blade expressions.
Mixing variable names inconsistently.