function HtmlSerializerRules::escape

Same name and namespace in other branches
  1. 11.x 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.