You are here

function ctools_css_assemble in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 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 optimized for human viewing.

2 calls to ctools_css_assemble()
CtoolsCssTestCase::testCssFilterURLHandling in tests/css.test
Test that in case that url is used, the colons survives filtering.
ctools_css_filter in includes/css.inc
Filter a chunk of CSS text.

File

includes/css.inc, line 218
CSS filtering functions. Contains a disassembler, filter, compressor, and decompressor.

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;
}