function render

8.x common.inc render(&$element)

Renders an element.

This function renders an element using drupal_render(). The top level element is shown with show() before rendering, so it will always be rendered even if hide() had been previously used on it.

Parameters

$element: The element to be rendered.

Return value

The rendered element.

See also

drupal_render()

show()

hide()

2 calls to render()
theme_file_widget_multiple in drupal/core/modules/file/file.field.inc
Returns HTML for a group of file upload widgets.
twig_render_var in drupal/core/themes/engines/twig/twig.engine
Wrapper around render() for twig printed output.
3 string references to 'render'
EntityManager::getRenderController in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Creates a new render controller instance.
hook_batch_alter in drupal/core/modules/system/system.api.php
Alter batch information before a batch is processed.
views_views_data in drupal/core/modules/views/views.views.inc
Implements hook_views_data().

File

drupal/core/includes/common.inc, line 4885
Common functions that many Drupal modules will need to reference.

Code

function render(&$element) {
  if (!$element && $element !== 0) {
    return NULL;
  }
  if (is_array($element)) {
    show($element);
    return drupal_render($element);
  }
  else {
    // Safe-guard for inappropriate use of render() on flat variables: return
    // the variable as-is.
    return $element;
  }
}