How Drupal Renders an HTML Page
In this chapter, we’ll start to dive into the layers of Drupal that deal with the frontend.
You will learn where a page comes from, how it is assembled, and by which parts. We’ll see what a template is and how it is used by Drupal (and Twig) to deliver an HTML page. Then we’ll talk about theme hooks and render arrays, the structures that Drupal has to mix templates and contents together.
Additionally, you will learn how to define a library to attach custom CSS and JavaScript files to a page.
Finally, you will see how to deliver the content of a controller action as a dialog.
By the end of the chapter, you’ll master the render pipeline of Drupal, and you’ll understand how Drupal builds all its pages.
This chapter will review the following key topics:
- What is a template?
- What is a render array?
- Controllers and blocks
- How to inject CSS and JavaScript into a template
- Alternate ways...