diff --git a/lessc.inc.php b/lessc.inc.php index 2292f219..07d55472 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -690,6 +690,7 @@ protected function compileProp($prop, $block, $out) { list(, $child) = $prop; $this->compileBlock($child); break; + case 'ruleset': case 'mixin': list(, $path, $args, $suffix) = $prop; @@ -720,6 +721,11 @@ protected function compileProp($prop, $block, $out) { $this->throwError("{$prop[1][0]} is undefined"); } + if(strpos($prop[1][0], "$") === 0) { + //Use Ruleset Logic - Only last element + $mixins = array(array_pop($mixins)); + } + foreach ($mixins as $mixin) { if ($mixin === $block && !$orderedArgs) { continue; @@ -2458,6 +2464,16 @@ protected function parseChunk() { $this->append(array("directive", $dirName, $dirValue)); return true; } + } elseif ($this->literal(":", true)) { + //Ruleset Definition + if (($this->openString("{", $dirValue, null, array(";")) || true) && + $this->literal("{")) + { + $dir = $this->pushBlock($this->fixTags(array("@".$dirName))); + $dir->name = $dirName; + if (isset($dirValue)) $dir->value = $dirValue; + return true; + } } } diff --git a/tests/inputs/ruleset.less b/tests/inputs/ruleset.less new file mode 100644 index 00000000..68e9038b --- /dev/null +++ b/tests/inputs/ruleset.less @@ -0,0 +1,11 @@ +@detached-ruleset: { background: red; border: none; }; +@detached-ruleset: { background: blue; }; + +body { + .top { + @detached-ruleset(); + } +} +.top { + @detached-ruleset(); +} \ No newline at end of file diff --git a/tests/outputs/ruleset.css b/tests/outputs/ruleset.css new file mode 100644 index 00000000..ed453096 --- /dev/null +++ b/tests/outputs/ruleset.css @@ -0,0 +1,6 @@ +body .top { + background: blue; +} +.top { + background: blue; +}