function drupal_render_children

Same name in other branches
  1. 7.x includes/common.inc \drupal_render_children()

Renders children of an element and concatenates them.

Parameters

array $element: The structured array whose children shall be rendered.

array $children_keys: (optional) If the keys of the element's children are already known, they can be passed in to save another run of \Drupal\Core\Render\Element::children().

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered HTML of all children of the element.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Avoid early rendering when possible or loop through the elements and render them as they are available.

See also

\Drupal\Core\Render\RendererInterface::render()

https://www.drupal.org/node/2912757

File

core/includes/common.inc, line 835

Code

function drupal_render_children(&$element, $children_keys = NULL) {
    if ($children_keys === NULL) {
        $children_keys = Element::children($element);
    }
    $output = '';
    foreach ($children_keys as $key) {
        if (!empty($element[$key])) {
            $output .= \Drupal::service('renderer')->render($element[$key]);
        }
    }
    return Markup::create($output);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.