Change record status: 
Project: 
Introduced in branch: 
8.0.x
Introduced in version: 
8.0.0-rc3
Description: 

In summary, per issue #1898432, rendering of children is now implicit when something is printed using twig, so that the drupal_render_children() function no longer needs to be called in preprocess. This was done as a follow-up to the work to convert PHPTemplate templates to Twig.

In addition, if early rendering is necessary, child elements should be iterated and rendered individually.

Before (D7)

$variables['children'] = drupal_render_children($form);

After (D8) - Twig

Early rendering should be avoided when possible and children should be rendered in the Twig template:

{{ form }}

You can also hide elements using the |without filter:

<div{{ content_attributes }}>
  {{ content|without('links') }}
</div>

{{ content.links }}

You can also hide multiple elements:

{{ form|without('advanced', 'actions') }}

After (D8) - PHP

If early rendering is necessary, loop through the elements and render them as they are available (this example is borrowed from template_process_toolbar() in toolbar.module in Drupal core):

  foreach (Element::children($element) as $key) {
    // Early rendering to collect the wrapper attributes from
    // ToolbarItem elements.
    if (!empty($element[$key])) {
      Drupal::service('renderer')->render($element[$key]);
    }
   
    // Perform any additional manipulation of $element...

Additional Information

The drupal_render_children() function was only ever required because of an infinite loop issue when drupal_render() was called from within a theme preprocess function. See #1898432-20: node.module - Convert PHPTemplate templates to Twig.

The infinite loop issue has been resolved in core by #1920886: drupal_render() should check if it's rendering a 'render element' and if so call drupal_render_children() (inline) instead, which introduced a new internal property, #render_children, usually only set in ThemeManagerInterface::render() to prevent the infinite loop.

Impacts: 
Module developers
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done