mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
WIP #10764
This commit is contained in:
@ -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>";
|
||||
}
|
||||
|
Reference in New Issue
Block a user