function sassy_parse in Sassy 7
Same name and namespace in other branches
- 7.3 sassy.module \sassy_parse()
- 7.2 sassy.module \sassy_parse()
Parse a SCSS string and transform it into CSS.
@params $data A SCSS string.
Return value
The transformed CSS as a string.
1 call to sassy_parse()
- sassy_pre_render in ./sassy.module 
- Builds the SASS cache. Should only be invoked by drupal_render().
File
- ./sassy.module, line 184 
- Handles compiling of .sass / .scss files.
Code
function sassy_parse($file, $data, $syntax) {
  drupal_alter('sassy_pre', $data, $file, $syntax);
  $placeholders = _sassy_match_media_queries($data, $syntax);
  $variables = _sassy_match_variables($data, $syntax);
  $data = str_replace($placeholders, array_keys($placeholders), $data);
  // Quote all URLs here so PhamlP doesn't remove them.
  $data = preg_replace("/url\\(([^'\")]+)\\)/i", "url('\$1')", $data);
  // Execute the compiler.
  $parser = new SassParser(array(
    'style' => 'nested',
    'cache' => FALSE,
    'syntax' => $syntax,
    'extensions' => array(
      'compass' => array(),
    ),
  ));
  $output = $parser
    ->toCss($data, FALSE);
  $output = str_replace(array_keys($placeholders), $placeholders, $output);
  $output = str_replace(array_keys($variables), $variables, $output);
  drupal_alter('sassy_post', $data, $syntax);
  return $output;
}