You are here

function ctools_css_assemble in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/css.inc \ctools_css_assemble()

Re-assemble a css string and format it nicely.

Parameters

array $css_data: An array of css data, as produced by @see ctools_css_disassemble() disassembler and the @see ctools_css_filter_css_data() filter.

Return value

string $css css optimized for human viewing.

1 call to ctools_css_assemble()
ctools_css_filter in includes/css.inc
Filter a chunk of CSS text.

File

includes/css.inc, line 241

Code

function ctools_css_assemble($css_data) {

  // Initialize the output.
  $css = '';

  // Iterate through all the statements.
  foreach ($css_data as $selector_str => $declaration) {

    // Add the selectors, separating them with commas and line feeds.
    $css .= strpos($selector_str, ',') === FALSE ? $selector_str : str_replace(", ", ",\n", $selector_str);

    // Add the opening curly brace.
    $css .= " {\n";

    // Iterate through all the declarations.
    foreach ($declaration as $property => $value) {
      $css .= "  " . $property . ": " . $value . ";\n";
    }

    // Add the closing curly brace.
    $css .= "}\n\n";
  }

  // Return the output.
  return $css;
}