W3cubDocs

/Drupal 8

class Html

Provides DOMDocument helpers for parsing and serializing HTML strings.

Hierarchy

  • class \Drupal\Component\Utility\Html

Related topics

Utility classes and functions
Overview of utility classes and functions for developers.

File

core/lib/Drupal/Component/Utility/Html.php, line 10

Namespace

Drupal\Component\Utility

Members

Name Modifiers Type Description
Html::$classes protected static property An array of previously cleaned HTML classes.
Html::$isAjax protected static property Stores whether the current request was sent via AJAX.
Html::$seenIds protected static property An array of IDs, including incremented versions when an ID is duplicated.
Html::$seenIdsInit protected static property An array of the initial IDs used in one request.
Html::cleanCssIdentifier public static function Prepares a string for use as a CSS identifier (element, class, or ID name).
Html::decodeEntities public static function Decodes all HTML entities including numerical ones to regular UTF-8 bytes.
Html::escape public static function Escapes text by converting special characters to HTML entities.
Html::escapeCdataElement public static function Adds comments around a <!CDATA section in a \DOMNode.
Html::getClass public static function Prepares a string for use as a valid class name.
Html::getId public static function Prepares a string for use as a valid HTML ID.
Html::getUniqueId public static function Prepares a string for use as a valid HTML ID and guarantees uniqueness.
Html::load public static function Parses an HTML snippet and returns it as a DOM object.
Html::normalize public static function Normalizes an HTML snippet.
Html::resetSeenIds public static function Resets the list of seen IDs.
Html::serialize public static function Converts the body of a \DOMDocument back to an HTML snippet.
Html::setIsAjax public static function Sets if this request is an Ajax request.

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Html.php/class/Html/8.1.x