Home > Backend Development > PHP Tutorial > Blade template engine-common grammar formats Three Kingdoms blade textblade superblade

Blade template engine-common grammar formats Three Kingdoms blade textblade superblade

WBOY
Release: 2016-07-29 08:48:55
Original
1356 people have browsed it
  1. Print variables or default values. This syntax will automatically escape the html tags in the variable content, causing the html tags to be output as they are.
    Welcome, {{ $name or 'California' }}

  2. Print the original content of the variable , usage without escaping
    {!! 'My list <script>alert("spam spam spam!")</script>' !!}

  3. Loop
    Normal loop
    @foreach ($lists as $list)
    <li>{{ $list }}</li>
    @endforeach
    Handle the case when the variable is empty
    @forelse ($lists as $list)
    <li>{{ $list }}</li>
    @empty
    <li>You don't have any lists saved.
    if judgment

    @if (count($lists) > 1)
  4. @elseif ()
    @else
    @endif

    Use the following syntax in the template to create content Placeholder

    @yield('content')

  5. Use the template in the view using the following syntax

    @extends('layouts.master')

  6. Use the following syntax to populate the placeholder content

    @section('content')
  7. content
    @endsection

    Use the following syntax to reference sub-php files

    @include('partial')
  8. @include('partials.row', ['link' => $link])
    , pass parameters to sub-files
    How to decide whether to use some public content in sub-views

    @section('advertisement')
  9. parent content
    @show
    The advertising section defined by the above syntax will not be displayed directly in the subview. @show is equivalent to @endsection @yield('advertisement')
    @section('advertisement')
    @parent
    child content
    @endsection
    Only if @parent is used here, the content defined in the advertisement in the template will be displayed in the subview10. Syntax for referencing css, js, etc. 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') !!}
    here It should be noted that if you write a standard html tag, you need to add a '/' symbol in front of the path

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template