Skip to content

Instantly share code, notes, and snippets.

@steveoliver
Created June 6, 2013 19:54
Show Gist options
  • Select an option

  • Save steveoliver/5724411 to your computer and use it in GitHub Desktop.

Select an option

Save steveoliver/5724411 to your computer and use it in GitHub Desktop.
Discussing this on our call today, Fabianx pointed out one possibility. Take our example of image field instances within a node template:
To get at the src (or any other) attribute of the first image field instance, one would print:
<code>{{ content.field_image.attributes.src }}</code>
1. The field <code>attributes</code> have not yet been prepared in the context of the parent node template.
2. <code>TwigTemplate::getAttribute()</code> determines the attribute does not exist and then calls a function, tentatively named <code>render_structure()</code>, which returns the variables as would be available in the child template.
3. Then .src and other variables are available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment