class AttributeString

A class that represents most standard HTML attributes.

To use with the Attribute class, set the key to be the attribute name and the value the attribute value.

 $attributes = new Attribute(array());
 $attributes['id'] = 'socks';
 $attributes['style'] = 'background-color:white';
 echo '<cat ' . $attributes . '>';
 // Produces: <cat id="socks" style="background-color:white">.


Expanded class hierarchy of AttributeString

See also



drupal/core/lib/Drupal/Core/Template/AttributeString.php, line 27
Definition of Drupal\Core\Template\AttributeString.


View source
class AttributeString extends AttributeValueBase {

   * Implements the magic __toString() method.
  public function __toString() {
    $this->printed = TRUE;
    return String::checkPlain($this->value);



Contains filters are case sensitive
Namesort descending Modifiers Type Description
AttributeString::__toString public function Implements the magic __toString() method. Overrides AttributeValueBase::__toString
AttributeValueBase::$name protected property The name of the value.
AttributeValueBase::$printed protected property Whether this attribute hsa been printed already.
AttributeValueBase::$value protected property The value itself.
AttributeValueBase::printed public function Whether this attribute hsa been printed already.
AttributeValueBase::render public function Returns a string representation of the attribute.
AttributeValueBase::__construct public function Constructs a \Drupal\Core\Template\AttributeValueBase object.