You are here

function sassy_pick_files in Sassy 7

Picks all SCSS and SASS files from an array of stylesheets.

Parameters

$items: An array of stylesheets.

Return value

The extracted files as an array.

1 call to sassy_pick_files()
sassy_pre_render in ./sassy.module
Builds the SASS cache. Should only be invoked by drupal_render().

File

./sassy.module, line 123
Handles compiling of .sass / .scss files.

Code

function sassy_pick_files(&$items) {
  $files = array(
    '#stylesheets' => array(),
    '#includes' => array(),
  );
  foreach ($items as $key => $file) {
    $extension = drupal_substr($file['data'], -5);
    if ($file['type'] == 'file' && in_array($extension, array(
      '.scss',
      '.sass',
    ))) {
      $syntax = drupal_substr($extension, -4);
      if ($file['media'] == 'include') {
        $files['#includes'][$syntax][$key] = $file;
        unset($items[$key]);
      }
      else {
        $file['syntax'] = $syntax;
        $file['recompile'] = isset($file['recompile']) ? $file['recompile'] : FALSE;

        // If the file is set to recompile on every page load then we don't want
        // it to be aggregated.
        $file['preprocess'] = !empty($file['recompile']) ? FALSE : $file['preprocess'];
        $files['#stylesheets'][$key] = $file;
      }
    }
  }
  return $files;
}