SlideShare a Scribd company logo
Study Program of Information Systems
Faculty of Engineering and Computer Science
SY. 2020-2021
Andi Nurkholis, S.Kom., M.Kom.
November 02, 2020
2
3
Blade is the simple, yet powerful templating engine
provided with Laravel. Blade view files use the .blade.php
file extension and are typically stored in the
resources/views directory.
4
It does not restrict the
developer from using
plain PHP code in views.
The blade views thus
designed, are compiled
and cached until they are
modified.
The main advantage of using blade template
engine is that it allow use to create master
template which can be extended by other
individual pages.
5
Two of the primary benefits of using Blade are template
inheritance and sections. We can define a blade page as
a combination of layout and sections.
6
7
If you want to display any variable inside blade view, you can do it
be simply wrapping the variable in “curly” braces. By default,
Blade {{ }} statements are automatically sent through PHP's
htmlspecialchars function to prevent XSS attacks.
Above syntax is equivalent to <?= $variable ?> in plain PHP
8
The Blade template engine comes with convenient short-
cuts for using PHP control statements. Blade template
engine provides the @if, @elseif, @else and @endif
directives to construct equivalent PHP if statement and
its counterparts.
9
10
Blade template engine provides @for, @endfor,
@foreach, @endforeach, @while and @endwhile
directives to construct equivalent PHP loop
statements.
Blade template engine provides
@include(‘viewname’) directive for including a
view inside another view.
The child view will have all the variables that
are available to parent view.
11
As we know most of the web applications follows the
same layout across all the pages, so the better approach
is to define a master template where we can place all the
boilerplate.
In Laravel, blade template engine allow us to define a
master template which can be extended by other
individual pages.
12
Step 1:- Create a new folder “layout” in /resources/views/
directory.
Step 2:- Create a new file “master.blade.php” in
/resources/views/layouts/ directory.
Step 3:- Copy the following code in the “master.blade.php” file we
created.
13
14
• @yield(‘title’) is used to display the value of the title
• @section(‘sidebar’) is used to define a section named
sidebar
• @endsection is used to end a section named sidebar
• @show is used to display the contents of a section
• @yield(‘content’) is used to display the contents of
content
15
16
We will now show you how to extend the
previously master layout we just created.
Step 1:- Create a new view file page.blade.php in
/resources/views/
Step 2:- Copy the following code in
page.blade.php file
17
• @extends(‘layouts.master’) extends the master layout
• @section(‘title’, ‘Page Title’) sets the value of the title
section.
• @section(‘sidebar’) defines a sidebar section in the
child page of master layout
• @parent displays the content of the sidebar section,
defined in the master layout.
18
• @endsection ends the sidebar section
• @section(‘content’) defines the content section
• @endsection ends the content section
19
Now we can create a simple foundation for the front-end views
for our site. Layouts, slices, and pages all work together to
create an easy templating system. There is much more that
Laravel Blade Templating and I encourage you to take a look at
what else we can do
20
Andi Nurkholis, S.Kom., M.Kom.
September 28, 2020November 02, 2020
Study Program of Information Systems
Faculty of Engineering and Computer Science
SY. 2020-2021

More Related Content

PDF
Web Programming - 6 Bootstrap Framework
PDF
Web Programming - 8 Database, Model and Eloquent
PDF
Web Programming - 4 Route, View, and Controller
PDF
Web Programming - 10 JavaScript
PDF
Web Programming - 9 Create, Read, Update and Delete
PDF
Web Programming - 11 SweetAlert2, DataTables, and WYSIWYG API
PPSX
Asp.net Overview
PPTX
Continuous Deployment with SSDT
Web Programming - 6 Bootstrap Framework
Web Programming - 8 Database, Model and Eloquent
Web Programming - 4 Route, View, and Controller
Web Programming - 10 JavaScript
Web Programming - 9 Create, Read, Update and Delete
Web Programming - 11 SweetAlert2, DataTables, and WYSIWYG API
Asp.net Overview
Continuous Deployment with SSDT

What's hot (20)

PDF
Extensibility of a database api with js
PPTX
Sq lite
DOCX
Oracle jet
PPTX
Mvc Brief Overview
PDF
Creating data centric microservices
PPTX
News web application
PPTX
Introduction to asp.net
PDF
Struts presentation
PPT
Struts(mrsurwar) ppt
PDF
Scaling ArangoDB on Mesosphere DCOS
PPTX
Session 1
PDF
5 fruits-of-extbase
PPT
Asp.net mvc
PDF
Asp 1a-aspnetmvc
PDF
ASP.Net | Sabin Saleem
PPTX
An overview of microsoft mvc dot net
PDF
Model View Controller (MVC)
PDF
GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...
PDF
New features of entity framework 7
PPTX
asp-net.pptx
Extensibility of a database api with js
Sq lite
Oracle jet
Mvc Brief Overview
Creating data centric microservices
News web application
Introduction to asp.net
Struts presentation
Struts(mrsurwar) ppt
Scaling ArangoDB on Mesosphere DCOS
Session 1
5 fruits-of-extbase
Asp.net mvc
Asp 1a-aspnetmvc
ASP.Net | Sabin Saleem
An overview of microsoft mvc dot net
Model View Controller (MVC)
GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...
New features of entity framework 7
asp-net.pptx
Ad

Similar to Web Programming - 7 Blading Template (20)

PDF
AEM Sightly Deep Dive
PPS
Actionview
PDF
Object Oriented Programming with Laravel - Session 3
PPTX
Web technologies part-2
PPTX
Templates, partials and layouts
PDF
IRJET- Lightweight MVC Framework in PHP
PPTX
Codeigniter
PDF
Code igniter - A brief introduction
PPTX
cakephp UDUYKTHA (1)
PDF
re:dash is awesome
PDF
#6 - Template Engine: Mustache.js
PDF
Adobe Experience Manager Core Components
PDF
Introduction to sails.js
PDF
Architecture Specification - Visual Modeling Tool
PDF
Html5 deciphered - designing concepts part 1
PDF
vitepress-en.pdf
PDF
Introduction To Drupal
DOCX
ASP.NET MVC3 RAD
PDF
Introduction To CodeIgniter
AEM Sightly Deep Dive
Actionview
Object Oriented Programming with Laravel - Session 3
Web technologies part-2
Templates, partials and layouts
IRJET- Lightweight MVC Framework in PHP
Codeigniter
Code igniter - A brief introduction
cakephp UDUYKTHA (1)
re:dash is awesome
#6 - Template Engine: Mustache.js
Adobe Experience Manager Core Components
Introduction to sails.js
Architecture Specification - Visual Modeling Tool
Html5 deciphered - designing concepts part 1
vitepress-en.pdf
Introduction To Drupal
ASP.NET MVC3 RAD
Introduction To CodeIgniter
Ad

More from AndiNurkholis1 (20)

PDF
Data Structure - 4 Pointer & Linked List
PDF
Data Structure - 3 Array: Concept & Implementation
PDF
Data Structure - 1 Learning Contract
PDF
Data Structure - 2 Introduction of Data Structure
PDF
Struktur Data - 4 Pointer & Linked List
PDF
Struktur Data - 3 Array: Konsep & Implementasi
PDF
Struktur Data - 2 Pengantar Struktur Data
PDF
Struktur Data - 1 Kontrak Perkuliahan
PDF
Technopreneurship - 9 Analisis Biaya dan Keuangan
PDF
Pengantar Bisnis - 14 Manajemen Keuangan
PDF
Pengantar Bisnis - 13 Manajemen Operasi
PDF
Pengantar Bisnis - 12 Kebijakan Harga
PDF
Pengantar Bisnis - 11 Kebijakan Distribusi
PDF
Technopreneurship - 8 Manajemen Sumber Daya Manusia
PDF
Pengantar Bisnis - 10 Kebijakan Produk
PDF
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
PDF
Pengantar Bisnis - 9 Manajemen Pemasaran
PDF
Technopreneurship - 6 Business Plan
PDF
Pengantar Bisnis - 8 Kepemimpinan
PDF
Technopreneurship - 5 Model Bisnis
Data Structure - 4 Pointer & Linked List
Data Structure - 3 Array: Concept & Implementation
Data Structure - 1 Learning Contract
Data Structure - 2 Introduction of Data Structure
Struktur Data - 4 Pointer & Linked List
Struktur Data - 3 Array: Konsep & Implementasi
Struktur Data - 2 Pengantar Struktur Data
Struktur Data - 1 Kontrak Perkuliahan
Technopreneurship - 9 Analisis Biaya dan Keuangan
Pengantar Bisnis - 14 Manajemen Keuangan
Pengantar Bisnis - 13 Manajemen Operasi
Pengantar Bisnis - 12 Kebijakan Harga
Pengantar Bisnis - 11 Kebijakan Distribusi
Technopreneurship - 8 Manajemen Sumber Daya Manusia
Pengantar Bisnis - 10 Kebijakan Produk
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
Pengantar Bisnis - 9 Manajemen Pemasaran
Technopreneurship - 6 Business Plan
Pengantar Bisnis - 8 Kepemimpinan
Technopreneurship - 5 Model Bisnis

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
cuic standard and advanced reporting.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Cloud computing and distributed systems.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Machine Learning_overview_presentation.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectroscopy.pptx food analysis technology
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology
Building Integrated photovoltaic BIPV_UPV.pdf
Network Security Unit 5.pdf for BCA BBA.
Review of recent advances in non-invasive hemoglobin estimation
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Machine learning based COVID-19 study performance prediction
cuic standard and advanced reporting.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Cloud computing and distributed systems.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine Learning_overview_presentation.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Web Programming - 7 Blading Template

  • 1. Study Program of Information Systems Faculty of Engineering and Computer Science SY. 2020-2021 Andi Nurkholis, S.Kom., M.Kom. November 02, 2020
  • 2. 2
  • 3. 3 Blade is the simple, yet powerful templating engine provided with Laravel. Blade view files use the .blade.php file extension and are typically stored in the resources/views directory.
  • 4. 4 It does not restrict the developer from using plain PHP code in views. The blade views thus designed, are compiled and cached until they are modified.
  • 5. The main advantage of using blade template engine is that it allow use to create master template which can be extended by other individual pages. 5
  • 6. Two of the primary benefits of using Blade are template inheritance and sections. We can define a blade page as a combination of layout and sections. 6
  • 7. 7
  • 8. If you want to display any variable inside blade view, you can do it be simply wrapping the variable in “curly” braces. By default, Blade {{ }} statements are automatically sent through PHP's htmlspecialchars function to prevent XSS attacks. Above syntax is equivalent to <?= $variable ?> in plain PHP 8
  • 9. The Blade template engine comes with convenient short- cuts for using PHP control statements. Blade template engine provides the @if, @elseif, @else and @endif directives to construct equivalent PHP if statement and its counterparts. 9
  • 10. 10 Blade template engine provides @for, @endfor, @foreach, @endforeach, @while and @endwhile directives to construct equivalent PHP loop statements.
  • 11. Blade template engine provides @include(‘viewname’) directive for including a view inside another view. The child view will have all the variables that are available to parent view. 11
  • 12. As we know most of the web applications follows the same layout across all the pages, so the better approach is to define a master template where we can place all the boilerplate. In Laravel, blade template engine allow us to define a master template which can be extended by other individual pages. 12
  • 13. Step 1:- Create a new folder “layout” in /resources/views/ directory. Step 2:- Create a new file “master.blade.php” in /resources/views/layouts/ directory. Step 3:- Copy the following code in the “master.blade.php” file we created. 13
  • 14. 14
  • 15. • @yield(‘title’) is used to display the value of the title • @section(‘sidebar’) is used to define a section named sidebar • @endsection is used to end a section named sidebar • @show is used to display the contents of a section • @yield(‘content’) is used to display the contents of content 15
  • 16. 16 We will now show you how to extend the previously master layout we just created. Step 1:- Create a new view file page.blade.php in /resources/views/ Step 2:- Copy the following code in page.blade.php file
  • 17. 17
  • 18. • @extends(‘layouts.master’) extends the master layout • @section(‘title’, ‘Page Title’) sets the value of the title section. • @section(‘sidebar’) defines a sidebar section in the child page of master layout • @parent displays the content of the sidebar section, defined in the master layout. 18
  • 19. • @endsection ends the sidebar section • @section(‘content’) defines the content section • @endsection ends the content section 19
  • 20. Now we can create a simple foundation for the front-end views for our site. Layouts, slices, and pages all work together to create an easy templating system. There is much more that Laravel Blade Templating and I encourage you to take a look at what else we can do 20
  • 21. Andi Nurkholis, S.Kom., M.Kom. September 28, 2020November 02, 2020 Study Program of Information Systems Faculty of Engineering and Computer Science SY. 2020-2021