function drupal_pre_render_html_tag

Pre-render callback: Renders a generic HTML tag with attributes into #markup.

Parameters

array $element: An associative array containing:

  • #tag: The tag name to output. Typical tags added to the HTML HEAD:

    • meta: To provide meta information, such as a page refresh.
    • link: To refer to stylesheets and other contextual information.
    • script: To load JavaScript.
  • #attributes: (optional) An array of HTML attributes to apply to the tag.
  • #value: (optional) A string containing tag content, such as inline CSS.
  • #value_prefix: (optional) A string to prepend to #value, e.g. a CDATA wrapper prefix.
  • #value_suffix: (optional) A string to append to #value, e.g. a CDATA wrapper suffix.
1 string reference to 'drupal_pre_render_html_tag'
system_element_info in drupal/core/modules/system/system.module
Implements hook_element_info().

File

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

Code

function drupal_pre_render_html_tag($element) {
  $attributes = isset($element['#attributes']) ? new Attribute($element['#attributes']) : '';
  if (!isset($element['#value'])) {
    $markup = '<' . $element['#tag'] . $attributes . " />\n";
  }
  else {
    $markup = '<' . $element['#tag'] . $attributes . '>';
    if (isset($element['#value_prefix'])) {
      $markup .= $element['#value_prefix'];
    }
    $markup .= $element['#value'];
    if (isset($element['#value_suffix'])) {
      $markup .= $element['#value_suffix'];
    }
    $markup .= '</' . $element['#tag'] . ">\n";
  }
  $element['#markup'] = $markup;
  return $element;
}