Skip to content

Instantly share code, notes, and snippets.

@scor
Created February 20, 2015 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scor/9931b6ebf456caa356a6 to your computer and use it in GitHub Desktop.
Save scor/9931b6ebf456caa356a6 to your computer and use it in GitHub Desktop.
Rendering a twitter ID as a link using Twig in Drupal 8
<div{{ attributes }}>
{% if not label_hidden %}
<div{{ title_attributes.addClass('field-label') }}>{{ label }}</div>
{% endif %}
<div{{ content_attributes.addClass('field-items') }}>
{% for item in items %}
<div{{ item.attributes.addClass('field-item') }}><a href="https://twitter.com/{{ item.content['#markup']|trim('@') }}">{{ item.content }}</a></div>
{% endfor %}
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment