protected function parseArguments($string)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');

        $args = array();
        $hash = array();
        
        $regex = array(
            '([a-zA-Z0-9]+\="[^"]*")',      // cat="meow"
            '([a-zA-Z0-9]+\=\'[^\']*\')',   // mouse='squeak squeak'
            '([a-zA-Z0-9]+\=[a-zA-Z0-9]+)', // dog=false
            '("[^"]*")',                    // "some\'thi ' ng"
            '(\'[^\']*\')',                 // 'some"thi " ng'
            '([^\s]+)'                      // <any group with no spaces>
        );
        
        preg_match_all('#'.implode('|', $regex).'#is', $string, $matches);
        
        $stringArgs = $matches[0];
        $name = array_shift($stringArgs);
        
        $hashRegex = array(
            '([a-zA-Z0-9]+\="[^"]*")',      // cat="meow"
            '([a-zA-Z0-9]+\=\'[^\']*\')',   // mouse='squeak squeak'
            '([a-zA-Z0-9]+\=[a-zA-Z0-9]+)', // dog=false
        );
        
        foreach ($stringArgs as $arg) {
            //if it's an attribute
            if (!(substr($arg, 0, 1) === "'" && substr($arg, -1) === "'")
                && !(substr($arg, 0, 1) === '"' && substr($arg, -1) === '"')
                && preg_match('#'.implode('|', $hashRegex).'#is', $arg)
            ) {
                list($hashKey, $hashValue) = explode('=', $arg, 2);
                $hash[$hashKey] = $this->parseArgument($hashValue);
                continue;
            }
            
            $args[] = $this->parseArgument($arg);
        }
        
        return array($name, $args, $hash);
    }
protected function parseArguments($string)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');

        $args = array();
        $hash = array();
        
        $regex = array(
            '([a-zA-Z0-9]+\="[^"]*")',      // cat="meow"
            '([a-zA-Z0-9]+\=\'[^\']*\')',   // mouse='squeak squeak'
            '([a-zA-Z0-9]+\=[a-zA-Z0-9]+)', // dog=false
            '("[^"]*")',                    // "some\'thi ' ng"
            '(\'[^\']*\')',                 // 'some"thi " ng'
            '([^\s]+)'                      // <any group with no spaces>
        );
        
        preg_match_all('#'.implode('|', $regex).'#is', $string, $matches);
        
        $stringArgs = $matches[0];
        $name = array_shift($stringArgs);
        
        $hashRegex = array(
            '([a-zA-Z0-9]+\="[^"]*")',      // cat="meow"
            '([a-zA-Z0-9]+\=\'[^\']*\')',   // mouse='squeak squeak'
            '([a-zA-Z0-9]+\=[a-zA-Z0-9]+)', // dog=false
        );
        
        foreach ($stringArgs as $arg) {
            //if it's an attribute
            if (!(substr($arg, 0, 1) === "'" && substr($arg, -1) === "'")
                && !(substr($arg, 0, 1) === '"' && substr($arg, -1) === '"')
                && preg_match('#'.implode('|', $hashRegex).'#is', $arg)
            ) {
                list($hashKey, $hashValue) = explode('=', $arg, 2);
                $hash[$hashKey] = $this->parseArgument($hashValue);
                continue;
            }
            
            $args[] = $this->parseArgument($arg);
        }
        
        return array($name, $args, $hash);
    }
protected function parseArguments ( $ string ) { //Argument 1 must be a string Argument :: i ( ) -> test ( 1 , 'string' ) ; $ args = array ( ) ; $ hash = array ( ) ; $ regex = array ( '([a-zA-Z0-9]+\="[^"]*")' , // cat="meow" '([a-zA-Z0-9]+\=\'[^\']*\')' , // mouse='squeak squeak' '([a-zA-Z0-9]+\=[a-zA-Z0-9]+)' , // dog=false '("[^"]*")' , // "some\'thi ' ng" '(\'[^\']*\')' , // 'some"thi " ng' '([^\s]+)' // <any group with no spaces> ) ; preg_match_all ( '#' . implode ( '|' , $ regex ) . '#is' , $ string , $ matches ) ; $ stringArgs = $ matches [ 0 ] ; $ name = array_shift ( $ stringArgs ) ; $ hashRegex = array ( '([a-zA-Z0-9]+\="[^"]*")' , // cat="meow" '([a-zA-Z0-9]+\=\'[^\']*\')' , // mouse='squeak squeak' '([a-zA-Z0-9]+\=[a-zA-Z0-9]+)' , // dog=false ) ; foreach ( $ stringArgs as $ arg ) { //if it's an attribute if ( ! ( substr ( $ arg , 0 , 1 ) === "'" && substr ( $ arg , - 1 ) === "'" ) && ! ( substr ( $ arg , 0 , 1 ) === '"' && substr ( $ arg , - 1 ) === '"' ) && preg_match ( '#' . implode ( '|' , $ hashRegex ) . '#is' , $ arg ) ) { list ( $ hashKey , $ hashValue ) = explode ( '=' , $ arg , 2 ) ; $ hash [ $ hashKey ] = $ this -> parseArgument ( $ hashValue ) ; continue ; } $ args [ ] = $ this -> parseArgument ( $ arg ) ; } return array ( $ name , $ args , $ hash ) ; }
Handlebars will give arguments in a string
This will transform them into a legit argument
array

@param *string $string The argument string

@return array
Handlebars will give arguments in a string This will transform them into a legit argument array