Learn how to embed a Drupal single directory component (SDC) in a Twig template like node.html.twig. This tutorial explains how to pass props and slots to the component, how to determine the correct namespace and name, and how to choose between Twig’s {% include %}
and {% embed %}
when rendering an SDC. This technique is most often used by theme developers who override templates and compose a page using single directory components. A common scenario is expressing your design system as components in a theme, then overriding templates to use those components.
In this tutorial, we will:
- Reference a component from a parent Twig template file.
- Pass props and slot values to a component from that template.
- Decide when to use
{% include %}
or{% embed %}
based on the component's slot structure.
By the end of this tutorial, you’ll be able to embed a component into a Twig template and pass values to both its props and slots.
Over the years we've developed some techniques for practicing that we wanted to share. At Drupalize.Me we take hugging seriously. In this tutorial we'll look at the art, and science, of giving a good hug. The Merriam Webster dictionary defines the word hug as; squeeze (someone) tightly in one's arms, typically to express affection.
Did you know there are all kinds of different hugs that you can give? In this tutorial we'll look at:
- Defining what a hug is
- Some of the many types of hugs in the world today
- Precautions you may want to familiarize yourself with before hugging
- And the importance of proper technique
Lets go ahead and get started shall we?