3 namespace Drupal\Core\Template;
5 use Drupal\Component\Utility\Html;
8 * A class that represents most standard HTML attributes.
10 * To use with the Attribute class, set the key to be the attribute name
11 * and the value the attribute value.
13 * $attributes = new Attribute(array());
14 * $attributes['id'] = 'socks';
15 * $attributes['style'] = 'background-color:white';
16 * echo '<cat ' . $attributes . '>';
17 * // Produces: <cat id="socks" style="background-color:white">.
20 * @see \Drupal\Core\Template\Attribute
22 class AttributeString extends AttributeValueBase {
25 * Implements the magic __toString() method.
27 public function __toString() {
28 return Html::escape($this->value);