namuit / phamlp

Automatically exported from code.google.com/p/phamlp
0 stars 0 forks source link

Sass: css_location setting does nothing #120

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. $parser = new SassParser(array('css_location'=>'/path/to/my/css'));
2. $parser->toCss($myFile);
3. Look for file in /path/to/my/css

What is the expected output? What do you see instead?
No CSS file is generated, nor is their any method in the Sass library to 
generate a cached CSS file.

What version of the product are you using? On what operating system?
PHP 5.3, OSX

Please provide any additional information below.
I dug into the code, and it looks like css_location isn't being used anywhere 
at present. This would be damned handy for my team right now, so I'd love to 
know if it's on your radar for a future release.

Original issue reported on code.google.com by p...@8-bitdesign.com on 10 Jan 2012 at 6:40

GoogleCodeExporter commented 9 years ago
I hope this may help you:

  require_once APP_ROOT.'/vendor/PHamlP/sass/SassParser.php';
  $sass = new SassParser(array( 'cache' => true, 
                                'cache_location'    => APP_ROOT.'/tmp/scss',
                                'css_location'      => APP_ROOT.'/public/css',
                                'template_location' => APP_ROOT.'/app/scss',
                                'syntax'            => 'scss',
                        ));

  function scss_to_file($filename) {
    global $sass;
    $css = $sass->toCss($filename);
    $sourceFile = $sass->getFilename();
    $outputCssFile = pathinfo($filename, PATHINFO_FILENAME).'.css';
    $outputFile = $sass->getCss_location().'/'.$outputCssFile;
    if (!is_file($outputFile) || @filemtime($sourceFile) > @filemtime($outputFile)) {
      if (file_put_contents($outputFile, $css) === false)
        return false;
      @chmod($outputFile, 0644);
    } 
    return $outputCssFile;
  }

<link href="/css/<?= scss_to_file('style.scss') ?>" rel="stylesheet" 
media="screen">

Original comment by vadym.lu...@gmail.com on 16 Mar 2013 at 5:09