Simplified Twig template variables for Drupal.
Examples:
- Text fields:
{{ _article.title }}
- Text with summary:
{{ _artile.body.value }}
or{{ artile.body.summary }}
for the summary. - Link:
{{ _article.field_link.url }}
- Image:
<img src="{{ _article.field_image.url }} alt="{{ _article.field_image.alt }}" />
- Reference:
{{ _article.field_author.field_name }}
- And more...
The value module also ships with some helpful Twig filters.
- Image style:
{{ _article.field_image.uri|image_style('thumbnail') }}
- Markup:
{{ _article.body|markup }}
for rendering safe HTML markup. - Truncate:
{{ _article.title|truncate(10) }}
will truncate title to 10 characters. - Words:
{{ _article.title|words(5) }}
will truncate title to 5 words. - Pick:
{{ _article|pick(['field_name', 'field_author']) }}
to pick some values only. - Rename keys:
{{ _article|rename_keys(field_title: 'title') }}
to rename keys.
Create an issue in the issue queue.