How can I pass the loop.index from a view template to a node template? In a views template (views-view-unformatted.twig.html), I have
{% for row in rows %}  
    {% set row_index = loop.index0 %}  
    {{ row.content }}  
{% endfor %}  

where each row is processed in a node--view.twig.html.  How can I pass in row_index to the node--view.twig.html?  This is used simply to create an index.
This can be done using the preprocess function in my_theme.theme.  In the case above, the row was formatted in node--view--pagename.html.twig, so the preprocessor function name is mytheme_preprocess_node__view__pagename.  In the function, the view is iterated until the node matches the current node that is being processed, at that point, the row_index is determined and set and accessible in node--view--pagename.html.twig as {{ row_index }}.  

function fu_preprocess_node__view__pagename(&amp;$vars) {
    $view = $vars['view'];
    $node = $vars['node'];
    foreach($view-&gt;result as $key =&gt; $row){
        if($row-&gt;nid == $node-&gt;id()){
            $vars['row_index'] = $row-&gt;index;
        }
    }
}