Blade template engine-common syntax formats: Three Kingdoms bladetextbladesuperblade

Source: Internet
Author: User
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
  1. 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' }}

  2. Print original variable content without escaping
    {!! 'My list 《script》alert("spam spam spam!")《script》' !!}

  3. Loop
    Normal loop
    @foreach ($lists as $list)

  4. {{ $list }}

  5. @endforeach
    When the processing variable is null
    @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. Use the following syntax in the template to create content placeholders
    @yield('content')

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

  13. Use the following syntax to fill in placeholder content
    @section('content')
    content
    @endsection

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

  15. 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.

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.