function render

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()

6 calls to render()
Field::render_item in drupal/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
ImageThemeFunctionTest::testImageFormatterTheme in drupal/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
Tests usage of the image field formatters.
ImageThemeFunctionTest::testImageStyleTheme in drupal/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
Tests usage of the image style theme function.
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.

... See full list

5 string references to 'render'
EntityManager::getRenderController in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Creates a new render controller instance.
EntityManagerTest::testMethods in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php
Tests some methods on the manager.
EsiFragmentRendererTest::getInlineStrategy in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php
OverlaySubscriber::onRequest in drupal/core/modules/overlay/lib/Drupal/overlay/EventSubscriber/OverlaySubscriber.php
Performs check on the beginning of a request.
ViewsEntityRow::getDerivativeDefinitions in drupal/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php
Returns the definition of all derivatives of a base plugin.

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;
  }
}