Twig recipes: Making Drupal 8 render the markup you want

Jul 25, 2016

The addition of Twig has revolutionized the way we do theming in Drupal 8. Although very powerful, it is still fairly new to most of us. Using Twig requires us to take a new approach in order to produce the markup that we want. This session will be a presentation on how to use new features provided by Twig.

Some recipes that will be covered include:

* How can I pass information from Drupal to Twig?
* How can I create and assign classes directly in the Twig template?
* How can I render image fields as background images?
* How can I render node content as HTML attributes?
* How can I conditionally render fields based on the content of other fields?
* How can I use Twig filters to format numbers?

I am going to present some Drupal 8 modules that can help, but most of the heavy lifting will be done in the theme layer.

Hi! I'm Karim Boudjema, the developer and site-builder of this site.

I was wondering how could I giving back to the Drupal community all what it gave to me during the last 10 years, that's how the idea of this site came to me ... (read more)

Hi! I’m Santiago Rico, the web designer and themer of this site.

When Karim proposed me to design and theme this site for the Drupal community, I accepted immediately because the community is the main reason why I love Drupal so much.