element. * * Usage example: * @code * $build['hello'] = [ * '#type' => 'html_tag', * '#tag' => 'p', * '#value' => $this->t('Hello World'), * ]; * @endcode * * @RenderElement("html_tag") */ class HtmlTag extends RenderElement { /** * Void elements do not contain values or closing tags. * @see http://www.w3.org/TR/html5/syntax.html#syntax-start-tag * @see http://www.w3.org/TR/html5/syntax.html#void-elements */ static protected $voidElements = [ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', 'rect', 'circle', 'polygon', 'ellipse', 'stop', 'use', 'path', ]; /** * {@inheritdoc} */ public function getInfo() { $class = get_class($this); return [ '#pre_render' => [ [$class, 'preRenderConditionalComments'], [$class, 'preRenderHtmlTag'], ], '#attributes' => [], '#value' => NULL, ]; } /** * Pre-render callback: Renders a generic HTML tag with attributes. * * @param 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. * The value of #tag is escaped. * - #attributes: (optional) An array of HTML attributes to apply to the * tag. The attributes are escaped, see \Drupal\Core\Template\Attribute. * - #value: (optional) A string containing tag content, such as inline * CSS. The value of #value will be XSS admin filtered if it is not safe. * - #noscript: (optional) If TRUE, the markup (including any prefix or * suffix) will be wrapped in a