Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.593 diff -u -p -r1.593 theme.inc --- includes/theme.inc 26 Apr 2010 17:54:49 -0000 1.593 +++ includes/theme.inc 27 Apr 2010 22:43:13 -0000 @@ -1903,6 +1903,11 @@ function theme_feed_icon($variables) { /** * Returns HTML for a generic HTML tag with attributes. * + * This theme function may be used for tags appearing in the HTML HEAD of a + * document (specified via the #tag property in the passed $element). It is not + * recommended to use this theme function for tags appearing elsewhere, since + * more specific theme functions should be used for anything visible. + * * @param $variables * An associative array containing: * - element: An associative array describing the tag: @@ -1917,24 +1922,34 @@ function theme_feed_icon($variables) { * wrapper prefix. * - #value_suffix: (optional) A string to append to #value, e.g. a CDATA * wrapper suffix. + * - #empty: (optional) Can be set to TRUE or FALSE to force the rendered + * output to use the minimized tag syntax (e.g., "") or not + * (e.g., "") if its content is empty. Defaults to + * the XHTML guidelines (http://www.w3.org/TR/xhtml1/#guidelines). */ function theme_html_tag($variables) { + // @see http://www.w3.org/TR/xhtml1/dtds.html + static $empty_tags = array('area', 'base', 'basefont', 'br', 'col', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'); $element = $variables['element']; - if (!isset($element['#value'])) { - return '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . " />\n"; - } - else { - $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>'; + + $minimize = isset($element['#empty']) ? $element['#empty'] : in_array(strtolower($element['#tag']), $empty_tags); + $content = ''; + if (isset($element['#value'])) { if (isset($element['#value_prefix'])) { - $output .= $element['#value_prefix']; + $content .= $element['#value_prefix']; } - $output .= $element['#value']; + $content .= $element['#value']; if (isset($element['#value_suffix'])) { - $output .= $element['#value_suffix']; + $content .= $element['#value_suffix']; } - $output .= '\n"; - return $output; } + if ($minimize && !drupal_strlen($content)) { + $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . " />\n"; + } + else { + $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>' . $content . '\n"; + } + return $output; } /**