You are here

public static function SassFile::getFile in Sassy 7

* Returns the full path to a file to parse. * The file is looked for recursively under the load_paths directories and * the template_location directory. * If the filename does not end in .sass or .scss try the current syntax first * then, if a file is not found, try the other syntax. *

Parameters

string filename to find: * @param SassParser Sass parser * @return string path to file * @throws SassException if file not found

2 calls to SassFile::getFile()
SassImportNode::parse in phamlp/sass/tree/SassImportNode.php
* Parse this node. * If the node is a CSS import return the CSS import rule. * Else returns the rendered tree for the file. *
SassParser::parse in phamlp/sass/SassParser.php
* Parse a sass file or Sass source code and * returns the document tree that can then be rendered. * The file will be searched for in the directories specified by the * load_paths option. * If caching is enabled a cached version will be used…

File

phamlp/sass/SassFile.php, line 60

Class

SassFile
SassFile class. @package PHamlP @subpackage Sass

Code

public static function getFile($filename, $parser) {
  $ext = substr($filename, -5);
  foreach (self::$extensions as $i => $extension) {
    if ($ext !== '.' . self::SASS && $ext !== '.' . self::SCSS) {
      if ($i === 0) {
        $_filename = "{$filename}.{$parser->syntax}";
      }
      else {
        $_filename = $filename . '.' . ($parser->syntax === self::SASS ? self::SCSS : self::SASS);
      }
    }
    else {
      $_filename = $filename;
    }
    if (file_exists($_filename)) {
      return $_filename;
    }
    $paths = $parser->load_paths;
    if (!empty($parser->filename)) {
      $paths[] = dirname($parser->filename);
    }
    foreach ($paths as $loadPath) {
      $path = self::findFile($_filename, realpath($loadPath));
      if ($path !== false) {
        return $path;
      }
    }

    // foreach
    if (!empty($parser->template_location)) {
      $path = self::findFile($_filename, realpath($parser->template_location));
      if ($path !== false) {
        return $path;
      }
    }
  }
  throw new SassException('Unable to find {what}: {filename}', array(
    '{what}' => 'import file',
    '{filename}' => $filename,
  ));
}