Printing field item attributes with Twig / Drupal 8 In Drupal 7, I can do this in a custom field template to print the alt tag of an image:

&lt;?php print $item['#item']['alt']; ?&gt;


And though "item" seems to be a variable in Twig / drupal 8 fields, I can't seem to do the same thing. I've tried these:

{{ item.alt }}
{{ item.item.alt }}


These don't work but I don't get any errors either. Looking at the API does not give me much insight. I saw this gist but again, no alt tag rendered separately. My image is rendering the alt tag as i can see it in the code though.
The syntax to print the alt tag in that case is this:

{{ item['#item'].alt }}


Twig in Drupal 8 doesn't deal with hash keys like #item in render arrays cleanly. Part of the problem is that # signifies a comment in Twig, so {{ item.#item.alt }} wouldn't work. 

There is the possibility of working around this with a Twig extension to allow drilling down into hash attributes with the syntax {{ item.item.alt }} but I'm not sure if anyone is working on that. I should mention that Twig extensions can be added in contrib as well.