Join Joseph Lowery for an in-depth discussion in this video Understanding Laravel templating, part of Laravel 4 Essential Training.
- Laravel's built-in templating engine, Blade, is one of the most robust aspects of the framework. Now, before we begin coding with Blade, I wanted to take a few moments to review its most important features and capabilities. The Blade Templating Engine is one of two supported by Laravel, the other being the basic PHP file. A file is designated as a Blade template by being stored with a .blade.php extension.
Blade enjoys complete PHP support including both fully-formed PHP statements, and PHP functions such as date within Blade's recognized delimeters. The Blade syntax is very straightforward and easy to grasp. Double curly braces are used as the primary delimiters, and essentially equal a php echo statement. Use double curly braces in Blade to process variables, handle PHP functions such as substring, and also execute custom Laravel functions like link to.
Conditional Control is critical to any programming framework, and Laravel employs a simplified syntax, the @ symbol. With it you can integrate standard PHP @for statements, @foreach, note the use of the @ symbol for both the opening and closing indicators. You'll see the same pattern in most conditional operators. Also supported are @if, @else if, @else, @endif, and @while, @endwhile.
In addition, Laravel also includes a Conditional Control operator not available in PHP, @unless, which is basically the opposite of an if statement. Blade template structure is extremely flexible. You can incorporate external code snippets via the @include keyword. There's also extensive master page capabilities. Master pages are stored in the apps/views/layouts folder, and within a master page you can reserve an area of the page with the @yield keyword.
To display default content while keeping your options open, use @section, @show. To designate a child template include @extends at the top of that child template file. As you can tell, Blade comes with a great deal of power. We will begin exploring how to put that power to use in the next lesson.
Need a quick dive into Laravel? Check out this short primer, Up and Running with Laravel.
- Installing Laravel and Composer
- Routing requests
- Filtering routes
- Incorporating advanced controllers
- Creating a basic Blade template
- Developing a layout with child pages and forms
- Integrating a database
- Creating tables via migrations
- Outputting data
- Building a Laravel app
- Authenticating users
- Deploying Laravel code
Skill Level Intermediate
1. Introduction to Laravel
2. Fundamental Laravel Concepts
3. Outputting Laravel Code
4. Integrating Databases
5. Querying Data with Eloquent ORM
6. Building a Laravel App
7. Deploying Your Laravel Code
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.