function HtmlSerializerRules::escape

Same name in other branches
  1. 10 core/lib/Drupal/Component/Utility/HtmlSerializerRules.php \Drupal\Component\Utility\HtmlSerializerRules::escape()

File

core/lib/Drupal/Component/Utility/HtmlSerializerRules.php, line 28

Class

HtmlSerializerRules
Drupal-specific HTML5 serializer rules.

Namespace

Drupal\Component\Utility

Code

protected function escape($text, $attribute = FALSE) {
    $text = parent::escape($text, $attribute);
    if ($attribute) {
        $text = strtr($text, [
            '<' => '&lt;',
            '>' => '&gt;',
        ]);
    }
    return $text;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.