You are here

address-plain.html.twig in Address 8

Default template for the 'plain' address formatter.

Available variables:

  • given_name: Given name.
  • additional_name: Additional name.
  • family_name: Family name.
  • organization: Organization.
  • address_line1: First address line.
  • address_line2: Second address line.
  • postal_code: Postal code.
  • sorting_code: Sorting code.
  • dependent_locality: The dependent locality.
    • dependent_locality.code: Dependent locality code.
    • dependent_locality.name: Dependent locality name.
  • locality: The locality subdivision.
    • locality.code: Locality code.
    • locality.name: Locality name.
  • administrative_area: The administrative area subdivision.
    • administrative_area.code: Administrative area code.
    • administrative_area.name: Administrative area name.
  • country: The country.
    • country.code: Country code.
    • country.name: Country name.
  • address: An object that implements \Drupal\address\AddressInterface representing the address to be rendered. Only public methods can be used.
  • view_mode: View mode of the entity being rendered that this address field is attached to. For example, "teaser" or "full".

if a subdivision (dependent_locality, locality, administrative_area) was entered, the array will always have a code. If it's a predefined subdivision, it will also have a name. The code is always preferred.

File

templates/address-plain.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default template for the 'plain' address formatter.
  5. *
  6. * Available variables:
  7. * - given_name: Given name.
  8. * - additional_name: Additional name.
  9. * - family_name: Family name.
  10. * - organization: Organization.
  11. * - address_line1: First address line.
  12. * - address_line2: Second address line.
  13. * - postal_code: Postal code.
  14. * - sorting_code: Sorting code.
  15. * - dependent_locality: The dependent locality.
  16. * - dependent_locality.code: Dependent locality code.
  17. * - dependent_locality.name: Dependent locality name.
  18. * - locality: The locality subdivision.
  19. * - locality.code: Locality code.
  20. * - locality.name: Locality name.
  21. * - administrative_area: The administrative area subdivision.
  22. * - administrative_area.code: Administrative area code.
  23. * - administrative_area.name: Administrative area name.
  24. * - country: The country.
  25. * - country.code: Country code.
  26. * - country.name: Country name.
  27. * - address: An object that implements \Drupal\address\AddressInterface
  28. * representing the address to be rendered. Only public methods can be used.
  29. * - view_mode: View mode of the entity being rendered that this address field
  30. * is attached to. For example, "teaser" or "full".
  31. *
  32. * if a subdivision (dependent_locality, locality, administrative_area) was
  33. * entered, the array will always have a code. If it's a predefined subdivision,
  34. * it will also have a name. The code is always preferred.
  35. *
  36. * @ingroup themeable
  37. */
  38. #}
  39. <p class="address" translate="no">
  40. {% if given_name or family_name %}
  41. {{ given_name }} {{ family_name }} <br>
  42. {% endif %}
  43. {% if organization %}
  44. {{ organization }} <br>
  45. {% endif %}
  46. {% if address_line1 %}
  47. {{ address_line1 }} <br>
  48. {% endif %}
  49. {% if address_line2 %}
  50. {{ address_line2 }} <br>
  51. {% endif %}
  52. {% if dependent_locality.code %}
  53. {{ dependent_locality.code }} <br>
  54. {% endif %}
  55. {% if locality.code or postal_code or administrative_area.code %}
  56. {{ locality.code }} {{ postal_code }} {{ administrative_area.code }} <br>
  57. {% endif %}
  58. {{ country.name }}
  59. </p>