This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
***: Buffer Playback... | |
Fabianx: [15:17:27] steveoliver: pong | |
Fabianx: [15:17:50] steveoliver: Can you pass me the link to drill able again (sorry during moving, not much time left  ) | |
***: Playback Complete. | |
steveoliver: 2008450 | |
Druplicon: https://drupal.org/node/2008450 => Provide for a drillable variable structure in Twig templates [#2008450] => Drupal core, theme system, major, needs work, 12 comments, 10 IRC mentions | |
steveoliver: Fabianx: ^^ | |
Fabianx: steveoliver: So implementation is: | |
Fabianx: ( proof-of-concept) | |
Fabianx: * Add a new parameter to render and theme. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3 id="bestpractices">Best Practices in Preprocess Functions and Twig Templates</h3> | |
In order to minimize wasteful calls to unneeded resources and make Drupal 8 themeing as performant as possible, please follow these best practices: | |
<ol> | |
<li>Always call <code>t()</code> within templates; never call t() in preprocess.</li> | |
<li>Always return render arrays instead of ever calling <code>theme()</code> within a preprocess function.</li> | |
</ol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// controller arguments | |
$arguments = $this->resolver->getArguments($request, $controller); | |
// call controller | |
// i.e. from menu_execute_active_handler | |
// | |
$response = call_user_func_array($controller, $arguments); | |
// if controller wasn't smart enough to return a complete response... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- BEGIN 'comment_wrapper__node_article' THEME MARKUP --> | |
<!-- FROM core/themes/stark/templates/node/node--1.html.twig --> | |
<!-- FILE NAME SUGGESTIONS: | |
x node--1.html.twig | |
* node--article.html.twig | |
* node.html.twig | |
--> | |
<article id="node-1"> | |
<h2>Title</h2> | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# modules/user/templates/user-login-block.html.twig #} | |
{% block "login-link" %} | |
<div class="user-login-block-link"> | |
{{ link }} | |
</div> | |
{% endblock %} | |
NewerOlder