Blade: Blade template engine-common syntax format: print a variable or default. this syntax automatically escapes the html tag in the variable content so that the html tag outputs the Welcome as is, {$ nameorCalifornia} print original variable content. escape is not used {!! Mylist !!} Loop common loop @ foreach ($ listsas $ list) {$ list
Print the variable or default value. this syntax automatically escapes the html tag in the variable content so that the html tag is output as is.
Welcome, {{ $name or 'California' }}
Print original variable content without escaping
{!! 'My list 《script》alert("spam spam spam!")《script》' !!}
Loop
Normal loop
@foreach ($lists as $list)
{{ $list }}
@endforeach
When the processing variable is null
@forelse ($lists as $list)
- {{ $list }}
@empty
- You don't have any lists saved.
@endforelse
If judgment
@if (count($lists) > 1)
@elseif ()
@else
@endif
Use the following syntax in the template to create content placeholders
@yield('content')
Use the following syntax in the view to use the template
@extends('layouts.master')
Use the following syntax to fill in placeholder content
@section('content')
content
@endsection
Use the following syntax to reference a child php file
@include('partial')
@include('partials.row', ['link' => $link])
, Passing parameters to the subfile
How to determine whether to use public content in the subview
@section('advertisement')
parent content
@show
The advertisement section defined in the preceding syntax is not directly displayed in the subview. @ show is equivalent to @ endsection @ yield ('advertisement ')
@section('advertisement')
@parent
child content
@endsection
Only @ parent is used here. the content defined in advertisement in the template is displayed in the subview.
10. reference the css, js, and other syntaxes in the template.
{!! HTML::style('css/app.min.css') !!}
{!! HTML::script('javascript/jquery-1.10.1.min.js') !!}
{!! HTML::script('javascript/bootstrap.min.js') !!}
{!! HTML::image('images/logo.png', 'TODOParrot logo') !!}
Note that if you write standard html tags, you must add a '/' symbol to the path.