Blade template Engine-common syntax format Three Kingdoms Blade TextBlade SuperBlade

Source: Internet
Author: User
  1. Print variables or default values, this syntax automatically escapes HTML tags in variable content, making HTML tags output as they are
    Welcome, {{ $name or 'California' }}

  2. Print the original contents of the variable without escaping the usage
    {!! 'My list ' !!}

  3. Cycle
    Normal cycle
    @foreach ($lists as $list)

  4. {{ $list }}

  5. @endforeach
    case where the processing variable is empty
    @forelse ($lists as $list)
  6. {{ $list }}

  7. @empty
  8. You don't have any lists saved.

  9. @endforelse

  10. If judgment
    @if (count($lists) > 1)
    @elseif ()
    @else
    @endif

  11. Create placeholders for content in templates using the following syntax
    @yield('content')

  12. Use the following syntax in the view using the template
    @extends('layouts.master')

  13. Populate placeholder content with the following syntax
    @section('content')
    content
    @endsection

  14. Use the following syntax to refer to a child php file
    @include('partial')
    @include('partials.row', ['link' => $link]), passing parameters to the child file

  15. How to decide whether to use some common content in a child view
    @section (' advertisement ')
    parent content
    @show The advertisement section defined by
    above does not appear directly in the child view, @show equivalent to @endsection @yield (' advertisement ')
    @ Section (' advertisement ')
    @parent
    child content
    @endsection
    The content defined in advertisement in the template is displayed in the child view only if @parent is used here
    10. Syntax for referencing css,js in templates
    {!! 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 here that if you write a standard HTML tag, you need to precede a '/' symbol in the path

    To use the syntax above to install the HTML package
    11. Install HTML Package
    Composer require illuminate/html
    Configure provider and alias
    illuminate\html\ in config/app.php Htmlserviceprovider::class provider Configuration
    ' Form ' = Illuminate\html\formfacade::class, Facade Configuration

The above describes the blade template engine-the common syntax format, including the blade aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.