Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to include a sub-view named 'header' in a Blade template.
Laravel
@[1]('header')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @extends instead of @include
Using @section or @yield which are for layouts and sections
✗ Incorrect
The @include directive is used to insert a sub-view inside a Blade template.
2fill in blank
mediumComplete the code to include a sub-view named 'footer' passing a variable 'year' to it.
Laravel
@include('footer', ['[1]' => $year])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different key name than the variable expected in the sub-view
Passing the variable without an array
✗ Incorrect
The variable name 'year' is passed as a key in the array to the included view.
3fill in blank
hardFix the error in the code to correctly include a sub-view named 'nav' with a variable 'items'.
Laravel
@include('nav', [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the variable directly without array brackets
Using invalid syntax without quotes or brackets
✗ Incorrect
The second argument to @include must be an array mapping variable names to values.
4fill in blank
hardFill both blanks to include a sub-view named 'sidebar' and pass variables 'user' and 'role' to it.
Laravel
@include('[1]', ['[2]' => $user, 'role' => $role])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sub-view name
Using wrong variable key name
✗ Incorrect
The first blank is the sub-view name 'sidebar'. The second blank is the variable name 'user' passed to the sub-view.
5fill in blank
hardFill all three blanks to include a sub-view named 'card', passing variables 'title', 'content', and 'footer'.
Laravel
@include('[1]', ['[2]' => $title, '[3]' => $content, 'footer' => $footer])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sub-view name
Mismatching variable keys and variable names
✗ Incorrect
The sub-view name is 'card'. The variable keys are 'title' and 'content' matching the variables passed.