Laravel: Chapter 4 - Blade Templating

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

3 types of data to inject into a view

1) collections of data to iterate over 2) single objects that we're displaying on the page 3) services that generate data or views

Blade

Laravel's custom templating engine

curly braces

What Blade uses for its echo

Blade::directive('directive_name', function() { }

create custom blade directive with 'directive_name' and a function

@include('variable', ['text' => 'see'])

directive to include another view 'text' with data 'see' passed to it

@parent

directive to include content from the parent

@each('partial_name', $array, 'variable_name')

directive to loop over an array or collection

@inject('variable_name', 'class_instance_of')

inject statement for injecting a service directly into a view

custom directives

most useful when they simplify some form of repeated logic

@

prefix for directives

@section('content')

provide content for a section using @endsection

@section('title', 'Dashboard')

provide our content for the first section title as Dashboard without using @endsection

Blade directive

syntax used for mapping between a pattern and a PHP output

view()->share('variable', Post::recent());

the code you would place in public function boot() to share 'variable' globally with every view in your application

$slot

the variable in our component template that receives whatever content is passed in the @component directive

@component('view.name')

these are view partials meant to get content from the including template

@if (), @endif

what to use to write and end an if statement

@endsection

what to use when you're defining the content for a template in a child template

@show

what to use when you're defining the place for a section in the parent template

directives

what you use for all of your control structures, inheritance and custom functionality


Ensembles d'études connexes

CBA-396 International Business Test #2 JSU (Lenn Rainwater)

View Set