0
0
Laravelframework~10 mins

Why templates separate presentation from logic in Laravel - Test Your Understanding

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

Complete the Blade template code to display a variable called $title.

Laravel
<h1>[1]</h1>
Drag options to blanks, or click blank then click option'
A@title
B$title
Ctitle
D{{ $title }}
Attempts:
3 left
💡 Hint
Common Mistakes
Using @title instead of $title
Omitting the $ sign before the variable name
Using double curly braces inside the code incorrectly
2fill in blank
medium

Complete the Blade directive to include a child template named 'header'.

Laravel
@include('[1]')
Drag options to blanks, or click blank then click option'
Aheader
Bfooter
Csidebar
Dcontent
Attempts:
3 left
💡 Hint
Common Mistakes
Including the wrong template name
Forgetting to put the template name in quotes
Using @include without parentheses
3fill in blank
hard

Fix the error in the Blade if statement to check if $user is set.

Laravel
@if(isset([1]))
  <p>Welcome, {{ $user->name }}!</p>
@endif
Drag options to blanks, or click blank then click option'
A$user
Buser
CUser
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the $ sign before the variable
Using a wrong variable name
Using a capitalized variable name
4fill in blank
hard

Fill both blanks to create a Blade loop that iterates over $items and displays each $item.

Laravel
@foreach([1] as [2])
  <li>{{ $item }}</li>
@endforeach
Drag options to blanks, or click blank then click option'
A$items
B$item
Citems
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting $ signs for variables
Using plural for the loop variable
Using wrong variable names
5fill in blank
hard

Fill all three blanks to create a Blade conditional that checks if $count is greater than 0 and displays a message.

Laravel
@if([1] [2] [3])
  <p>There are items.</p>
@endif
Drag options to blanks, or click blank then click option'
A$count
B>
C0
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of >
Omitting $ sign for the variable
Using wrong numbers in the condition