"laravel5.1-0.0.3" "Basic 2" blade template inheritance Brief use

Source: Internet
Author: User

My original address: HTTP://WWW.JIANSHU.COM/P/0AA1153EAC22
What does a template inherit? Nature is to enhance the reuse of basic pages, facilitate the organization of the page document, but also easy to change the content used in many places, such as the page header, footer

1. Summary of Usage
    • @include (' Common.header ') contains a child view

    • @extends (' article.common.base ') inherit base template

    • @yield (' content ') View placeholder

    • Fill in the @section (' content ') @endsection inherit the template back into the view placeholder

    • {{---comment--}} Use of annotations in blade templates

2. Specific Use

2.1 New Article Base template base.blade.php

Create a new view base template directly using BOOTSTRAP4 template code and CDN
Path resources/views/article/common/base.blade.php

    artilce| title in this    
 
      
 
      
 
      
 
  {{--Contains page header--}} @include (' Article.common.header ') {{---the content inserted after inheritance-}} @yield (' content ') {{--Contains footer-}} @include (' Article.common.footer ')
2.2. Create sub-view file header and footer
    • Page header File resources/views/article/common/header.blade.php

 
  
   
                      Articles            
  
   
  
  • (current)
  • Write an article
  • Login
  • Registered
    • Footer File resources/views/article/common/footer.blade.php

                        

Articles

2.3 To inherit templates for reuse

New home page file in resources/views/article/index.blade.php

@extends (' Article.common.base ') @section (' content ')                    

The homepage of the inherited template is done!

{{--here is blade Comment-}} @endsection

2.4 How do I access it?

    • Routing and controller coordination are required, here is a simple routing implementation, click on the details, and the rest of the following sections

    • Write the following code in the app/http/routes.php routing registration file

Route::get ('/', function () {    return view (' Article.index ');});
    • Start your configuration of the laravel running server, such as my directory address under PHP artisan serve

    • Browser input: localhost:8000, you can see

3.

X BOOTSTRAP4 Start Template code
    • BOOTSTRAP4 Documentation

      
 
      
 
      
 
      
 
      
 
      
 
          

Hello, world!.

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