parse() public method

public parse ( $buffer )
Exemplo n.º 1
0
 function mixImport($import, $parentBlock, &$props)
 {
     list(, $url, $media) = $import;
     if (empty($media) && substr_compare($url, '.css', -4, 4) !== 0) {
         if ($this->importDisabled) {
             $props[] = array('raw', '/* import disabled */');
             return true;
         }
         $realPath = $this->findImport($url);
         if (!is_null($realPath)) {
             $this->addParsedFile($realPath);
             $parser = new lessc_parser($this, $realPath);
             $root = $parser->parse(file_get_contents($realPath));
             $root->isRoot = false;
             $root->parent = $parentBlock;
             // handle all the imports in the new file
             $pi = pathinfo($realPath);
             $this->mixImports($root, $pi['dirname'] . '/');
             // inject imported blocks into this block, local will overwrite import
             $parentBlock->children = array_merge($root->children, $parentBlock->children);
             // splice in the props
             foreach ($root->props as $prop) {
                 // leave a reference to the file where it came from
                 if (isset($prop[-1]) && !is_array($prop[-1])) {
                     $prop[-1] = array($parser, $prop[-1]);
                 }
                 $props[] = $prop;
             }
             return true;
         }
     }
     // fallback to regular css import
     $props[] = array('raw', '@import url("' . $url . '")' . ($media ? ' ' . $media : '') . ';');
     return false;
 }