You are here

protected function StyleBase::parseAttributes in GridStack 8.2

Parses the string attribute: role|navigation,data-something|some value.

No need to whitelist as this already requires admin priviledges. With admin privileges, the site is already taken over before playing around with attributes. However provides few basic sanitizations to satisfy curious playful editors.

@nottodo: Token support.

1 call to StyleBase::parseAttributes()
StyleBase::attributes in src/Plugin/gridstack/stylizer/StyleBase.php
Provides both CSS grid and js-driven attributes configurable via UI.

File

src/Plugin/gridstack/stylizer/StyleBase.php, line 210

Class

StyleBase
Provides the base styles.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

protected function parseAttributes(array &$attributes, $string = '') {
  foreach (explode(',', $string) as $data) {
    if (strpos($data, '|') !== FALSE) {
      list($key, $value) = array_pad(array_map('trim', explode('|', $data, 2)), 2, NULL);
      $key = mb_substr($key, 0, 2) === 'on' ? 'data-' . $key : $key;
      $attributes[$key] = Html::cleanCssIdentifier(strip_tags($value));
    }
  }
}