Browse Source

html class: Allow to pass array as content (#9782)

This allows for a little cleaner code
pull/9795/head
Pablo Zmdl 5 months ago
committed by GitHub
parent
commit
8bd1c93821
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      program/lib/Roundcube/html.php

5
program/lib/Roundcube/html.php

@ -63,7 +63,7 @@ class html
* *
* @param string $tagname Tag name * @param string $tagname Tag name
* @param array|string $attrib Tag attributes as key/value pairs, or 'class' attribute value * @param array|string $attrib Tag attributes as key/value pairs, or 'class' attribute value
* @param string $content Optional Tag content (creates a container tag)
* @param array|string $content Optional Tag content (creates a container tag)
* @param array $allowed List with allowed attributes, omit to allow all * @param array $allowed List with allowed attributes, omit to allow all
* *
* @return string The XHTML tag * @return string The XHTML tag
@ -81,6 +81,9 @@ class html
if (isset($content) || in_array($tagname, self::$containers)) { if (isset($content) || in_array($tagname, self::$containers)) {
$suffix = !empty($attrib['noclose']) ? $suffix : '</' . $tagname . '>' . $suffix; $suffix = !empty($attrib['noclose']) ? $suffix : '</' . $tagname . '>' . $suffix;
unset($attrib['noclose'], $attrib['nl']); unset($attrib['noclose'], $attrib['nl']);
if (is_array($content)) {
$content = implode('', $content);
}
return '<' . $tagname . self::attrib_string($attrib, $allowed) . '>' . $content . $suffix; return '<' . $tagname . self::attrib_string($attrib, $allowed) . '>' . $content . $suffix;
} }

Loading…
Cancel
Save