Beispiel #1
0
 public function compileFile($fname, $outFname = null)
 {
     if (!is_readable($fname)) {
         throw new Exception('load error: failed to find ' . $fname);
     }
     $pi = pathinfo($fname);
     $oldImport = $this->importDir;
     $this->importDir = (array) $this->importDir;
     $this->importDir[] = realpath($pi['dirname']) . '/';
     $this->allParsedFiles = array();
     $this->addParsedFile($fname);
     $parser = new avada_Less_Parser();
     $parser->SetImportDirs($this->getImportDirs());
     foreach ($this->libFunctions as $name => $func) {
         $parser->registerFunction($name, $func);
     }
     $parser->parseFile($fname);
     if (count($this->registeredVars)) {
         $parser->ModifyVars($this->registeredVars);
     }
     $out = $parser->getCss();
     $parsed = avada_Less_Parser::AllParsedFiles();
     foreach ($parsed as $file) {
         $this->addParsedFile($file);
     }
     $this->importDir = $oldImport;
     if ($outFname !== null) {
         return file_put_contents($outFname, $out);
     }
     return $out;
 }