From the course: Symfony 6 Essential Training

Unlock the full course today

Join today to access over 25,100 courses taught by industry experts.

Templates

Templates

- [Instructor] Templating in web apps standardizes the display layer and well-executed templating makes it easier for multiple devs to understand and work within it. Continuing in the Symfony Demo app, this is the route entry page as handled by the controller. And let's look at the corresponding Twig template. Of note on line one, this template extends from base.html.twig. I'll show that base template in a moment, but for now, let's walk forward in this template. The first piece of markup on line three specifies a body ID of homepage. Keep that in mind. Now, in base.html.twig on line 28, we see block body_id. This is the ID for the body element. For the homepage, it would be that value we saw of homepage. If we view source, the body has an ID of homepage. And in that homepage template, that string is the value that we provided. So when extending a template, you can overwrite the blocks. Looking at line nine and 10…

Contents