示例#1
0
 /**
  * Extracts the mixin bases
  * @param $source
  * @return return type
  */
 public function process($source)
 {
     print_r($source->get());
     exit;
     # Finds any selectors starting with =mixin-name
     if ($found = Scaffold_Helper_CSS::find_selectors('\\@mixin\\s+([0-9a-zA-Z_]+) (\\((.*?)\\))?', $source->get(), false)) {
         # Just to make life a little easier
         $full_base = $found[0];
         $base_names = $found['name'];
         $base_args = $found['args'];
         $base_props = $found['properties'];
         # Puts the mixin bases into a more suitable array
         foreach ($base_names as $key => $value) {
             $bases[$value]['properties'] = $base_props[$key];
             # If there are mixin arguments, add them
             $bases[$value]['params'] = $base_args[$key] != "" ? explode(',', $base_args[$key]) : array();
         }
         # Store this away for debugging
         $this->mixins = $bases;
         # Remove all of the mixin bases
         $source->set(str_replace($full_base, '', $source->get()));
     }
     print_r($this->mixins);
     exit;
 }
示例#2
0
 /**
  * Find selectors
  * @author Anthony Short
  * @test
  */
 public function Find_selectors()
 {
     $string = 'id{background:blue}#id2{color:blue}#id3{background-color:red}#id4{dbackground:blue}#id5{color:red;background:blue}';
     $expected = array(0 => 'id{background:blue}');
     $output = Scaffold_Helper_CSS::find_selectors('id', $string);
     $this->assertEquals($expected, $output);
     $expected = array(0 => '#id2{color:blue}');
     $output = Scaffold_Helper_CSS::find_selectors('#id2', $string);
     $this->assertEquals($expected, $output);
     $expected = array(0 => '#id3{background-color:red}');
     $output = Scaffold_Helper_CSS::find_selectors('#id3', $string);
     $this->assertEquals($expected, $output);
     $expected = array(0 => '#id4{dbackground:blue}');
     $output = Scaffold_Helper_CSS::find_selectors('#id4', $string);
     $this->assertEquals($expected, $output);
     $expected = array(0 => '#id5{color:red;background:blue}');
     $output = Scaffold_Helper_CSS::find_selectors('#id5', $string);
     $this->assertEquals($expected, $output);
 }