function drupal_html_class

drupal_html_class($class)

Prepares a string for use as a valid class name.

Do not pass one string containing multiple classes as they will be incorrectly concatenated with dashes, i.e. "one two" will become "one-two".

Parameters

$class: The class name to clean.

Return value

The cleaned class name.

File

includes/common.inc, line 3931
Common functions that many Drupal modules will need to reference.

Code

function drupal_html_class($class) {
  // The output of this function will never change, so this uses a normal
  // static instead of drupal_static().
  static $classes = array();

  if (!isset($classes[$class])) {
    $classes[$class] = drupal_clean_css_identifier(drupal_strtolower($class));
  }
  return $classes[$class];
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_html_class/7.x