This commit is contained in:
Daniel Gomez Pan
2016-02-07 16:39:41 +01:00
parent 2505e7ef63
commit cd7039e97c
5 changed files with 30 additions and 17 deletions

View File

@ -119,7 +119,7 @@ class BaseHtml
/**
* Generates a complete HTML tag.
* @param string $name the tag name
* @param string|boolean|null $name the tag name. If $name is null or false, the corresponding content will be rendered without any tag.
* @param string $content the content to be enclosed between the start and end tags. It will not be HTML-encoded.
* If this is coming from end users, you should consider [[encode()]] it to prevent XSS attacks.
* @param array $options the HTML tag attributes (HTML options) in terms of name-value pairs.
@ -137,6 +137,9 @@ class BaseHtml
*/
public static function tag($name, $content = '', $options = [])
{
if ($name === null || $name === false) {
return $content;
}
$html = "<$name" . static::renderTagAttributes($options) . '>';
return isset(static::$voidElements[strtolower($name)]) ? $html : "$html$content</$name>";
}