function drupal_html_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.

22 calls to drupal_html_class()
BlockTest::moveBlockToRegion in drupal/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
Moves a block to a given region via the UI and confirms the result.
BlockTest::testBlockModuleDisable in drupal/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
Tests blocks belonging to disabled modules.
BlockTestBase::moveBlockToRegion in drupal/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php
Moves a block to a given region via the UI and confirms the result.
contextual_pre_render_links in drupal/core/modules/contextual/contextual.module
Pre-render callback: Builds a renderable array for contextual links.
CustomBlockFormController::form in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
Overrides \Drupal\Core\Entity\EntityFormController::form().

... See full list

File

drupal/core/includes/common.inc, line 2638
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];
}