Using attributes in templates

Documentation of attributes object that appears in all html.twig templates.

Theming in Paragraphs for Drupal 8

Theming

The default paragraphs template is in paragraphs-item.html.twig.
It uses theme suggestions for other templates, the following suggestions are available:

  • paragraph__[view_mode] (e.g. paragraph--default.html.twig)
  • paragraph__[type] (e.g. paragraph--image.html.twig)
  • paragraph__[type]__[view_mode] (e.g. paragraph--image--default.html.twig)

Filters - Modifying Variables In Twig Templates

Filters in Twig can be used to modify variables. Filters are separated from the variable by a pipe symbol (|) and may have optional arguments in parentheses. Multiple filters can be chained. The output of one filter is applied to the next.

Example: {{ ponies|safe_join(", ")|lower}}

The list of filters that can be used in Twig templates for Drupal consists of all the filters in the Twig engine as well as some Drupal specific filters.

List of Twig filters.

Theming differences between Drupal 6, 7 & 8

This is a list of some of the most noteworthy changes in Drupal 8 that affect theming.

Template naming conventions

Drupal loads templates based on certain naming conventions. This allows you to override templates by adding them to your theme and giving them specific names.

After replacing a template you must rebuild the cache in order for Drupal to discover your new template.

You can debug Twig templates to figure out which templates are being used to output the markup for any given element.

Pages

Subscribe with RSS Subscribe to RSS - theming