Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Twig Field Value

Security covered Maintenance fixes only 45,522 sites

Part of the Twig ecosystem · 43 projects

Twig Field Value provides Twig filters to easily extract specific data from Drupal field render arrays. This gives developers more control over how field content is displayed in templates without needing to write complex preprocess functions.

Twig Field Value helps frontenders to get partial data from Drupal field render arrays. It gives them more control over the output without drilling deep into the render array or using preprocess functions.

Single field value

<strong>{{ content.field_name|field_label }}</strong>: {{ content.field_name|field_value }}

Multiple field values

<strong>{{ content.field_name|field_label }}</strong>: {{ content.field_name|field_value|safe_join(', ') }}

Single field properties

<span>Text format: {{ content.field_body|field_raw('text_format') }}.</span>

Referenced entities

<img src={{ file_url(content.field_image|field_target_entity.uri.value) }} alt={{ content.field_image|field_raw('alt') }} />

Filters:
- field_label : Returns the field label value.
- field_value : Returns the render array of the field value(s) without the field wrappers.
- field_raw: Returns raw field properties value(s).
- field_target_entity: Returns the referenced entity object(s) of an entity reference field.

Cache warning

The field_raw and field_target_entity filters do not provide any cache information. Without additional measures content printed with these filters will not be update when changed in the backend. You can workaround this by rendering the field in your template but not display the result. For example: {% set catch_cache = content.field_image|render %}

Drupal 9–11

Ask your assistant about Twig Field Value

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

5 tracked projects depend on this one

Activity

Tracked releases
3
Tracked since
Aug 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
2.0.5 Stable 9–11 Oct 8, 2024
2.0.4 Stable 9–11 Aug 30, 2024
2.0.3 Stable 9–11 Aug 27, 2024