public function SassImportNode::parse in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/tree/SassImportNode.php \SassImportNode::parse()
Parse this node. If the node is a CSS import return the CSS import rule. Else returns the rendered tree for the file.
Parameters
SassContext the context in which this node is parsed:
Return value
array the parsed node
File
- phpsass/
tree/ SassImportNode.php, line 49
Class
- SassImportNode
- SassImportNode class. Represents a CSS Import. @package PHamlP @subpackage Sass.tree
Code
public function parse($context) {
$imported = array();
foreach ($this->files as $file) {
if (preg_match(self::MATCH_CSS, $file)) {
return "@import {$file}";
}
else {
$file = trim($file, '\'"');
$files = SassFile::get_file($file, $this->parser, TRUE);
$tree = array();
if ($files) {
$tree = SassFile::get_tree(array_shift($files), $this->parser);
foreach ($files as $file) {
$file = SassFile::get_tree($file, $this->parser);
foreach ($file
->getChildren() as $child) {
$tree
->addChild($child);
}
}
}
if (!empty($tree)) {
$imported = array_merge($imported, $tree
->parse($context)->children);
}
}
}
return $imported;
}