You are here

README.txt in Twig Field Value 8

Same filename and directory in other branches
  1. 2.0.x README.txt
INTRODUCTION
------------

Twig Field Value allows Drupal themers to print field labels and field values
individually. It provides two Twig filters one that print a field label and
one that prints field value(s).

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.

USAGE
-----

To print the label and value of a field:
  <strong>{{ content.field_name|field_label }}</strong>: {{ content.field_name|field_value }}

To print the label and values of a field with multiple values:
  <strong>{{ content.field_name|field_label }}</strong>: {{ content.field_name|field_value|safe_join(', ') }}

To print image link and the alt text of an image:
  <img src={{ file_url(content.field_image|field_target_entity.uri.value) }} alt={{ content.field_image|field_raw('alt') }} />

The above examples assume that 'content.field_example' is the render array of
the of a field, as for example in a node template.

AUTHOR
------
Erik Stielstra (Sutharsan, https://www.drupal.org/u/sutharsan)

File

README.txt
View source
  1. INTRODUCTION
  2. ------------
  3. Twig Field Value allows Drupal themers to print field labels and field values
  4. individually. It provides two Twig filters one that print a field label and
  5. one that prints field value(s).
  6. Filters:
  7. - field_label : Returns the field label value.
  8. - field_value : Returns the render array of the field value(s) without
  9. the field wrappers.
  10. - field_raw : Returns raw field properties value(s).
  11. - field_target_entity : Returns the referenced entity object(s) of an entity
  12. reference field.
  13. USAGE
  14. -----
  15. To print the label and value of a field:
  16. {{ content.field_name|field_label }}: {{ content.field_name|field_value }}
  17. To print the label and values of a field with multiple values:
  18. {{ content.field_name|field_label }}: {{ content.field_name|field_value|safe_join(', ') }}
  19. To print image link and the alt text of an image:
  20. {{
  21. The above examples assume that 'content.field_example' is the render array of
  22. the of a field, as for example in a node template.
  23. AUTHOR
  24. ------
  25. Erik Stielstra (Sutharsan, https://www.drupal.org/u/sutharsan)