Helper modules
Core Twig can reach any field value, but these contrib modules make the common cases shorter and keep render-array internals out of your templates.
Twig Field Value
drupal.org/project/twig_field_valueTwig filters that pull a field's label, rendered value, raw properties or referenced entities out of a render array, without the field wrappers.
composer require drupal/twig_field_valueTwig filters
- |field_label
- Returns the field label value.
- |field_raw
- Returns raw field properties value(s).
- |field_target_entity
- Returns the referenced entity object(s) of an entity reference field.
- |field_value
- Returns the render array of the field value(s) without the field wrappers.
Used in 20 entries
- Title / label
- Published on
- Field label (any field type)
- Field output without wrappers
- Body
- Text (plain, plain long)
- Text (formatted, formatted long)
- Boolean
- Date
- Link — title
- Link — URL
- Link — plain text
- Link — options (attributes)
- Image — URI
- Address (address module)
- Media image — alt
- Media remote video — URL
- Reference — label (term name / node title)
- Reference — URL
- Reference — field on referenced entity
Twig Tweak
drupal.org/project/twig_tweakTwig functions and filters for common theming tasks, such as rendering blocks, views, entities and fields, and an image_style filter for file URIs.
composer require drupal/twig_tweakBamboo Twig
drupal.org/project/bamboo_twigA collection of Twig extensions for Drupal, including functions to render an image style straight from a file URI.
composer require drupal/bamboo_twigConfig Pages
drupal.org/project/config_pagesFieldable configuration pages for site-wide settings, with a Twig function to render a config page field anywhere.
composer require drupal/config_pages