Skip to content

Commit a56ffcb

Browse files
authored
Merge pull request #7 from phpugph/1.0
1.0
2 parents 54735d3 + 47af089 commit a56ffcb

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

src/HandlebarsCompiler.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ protected function generateOpen(array $node, array &$open)
499499

500500
if (!$helper) {
501501
//run noop
502-
$node['value'] = 'noop '.$node['value'];
502+
$node['value'] = 'noop ' . $node['value'];
503503
list($name, $args, $hash) = $this->parseArguments($node['value']);
504504
}
505505

@@ -645,12 +645,13 @@ protected function parseArguments($string)
645645
$hash = [];
646646

647647
$regex = [
648-
'([a-zA-Z0-9]+\="[^"]*")', // cat="meow"
649-
'([a-zA-Z0-9]+\=\'[^\']*\')', // mouse='squeak squeak'
650-
'([a-zA-Z0-9]+\=[a-zA-Z0-9]+)', // dog=false
651-
'("[^"]*")', // "some\'thi ' ng"
652-
'(\'[^\']*\')', // 'some"thi " ng'
653-
'([^\s]+)' // <any group with no spaces>
648+
'([a-zA-Z0-9\-_]+\="[^"]*")', // cat="meow"
649+
'([a-zA-Z0-9\-_]+\=\'[^\']*\')', // mouse='squeak squeak'
650+
'([a-zA-Z0-9\-_]+\=[a-zA-Z0-9_\./]+)', // dog=false dog=./woof dog=.././woof
651+
'([a-zA-Z0-9\-_]+\=@[a-zA-Z0-9_]+)', // dog=@woof
652+
'("[^"]*")', // "some\'thi ' ng"
653+
'(\'[^\']*\')', // 'some"thi " ng'
654+
'([^\s]+)', // <any group with no spaces>
654655
];
655656

656657
preg_match_all('#'.implode('|', $regex).'#is', $string, $matches);
@@ -659,16 +660,17 @@ protected function parseArguments($string)
659660
$name = array_shift($stringArgs);
660661

661662
$hashRegex = [
662-
'([a-zA-Z0-9]+\="[^"]*")', // cat="meow"
663-
'([a-zA-Z0-9]+\=\'[^\']*\')', // mouse='squeak squeak'
664-
'([a-zA-Z0-9]+\=[a-zA-Z0-9]+)', // dog=false
663+
'([a-zA-Z0-9\-_]+\="[^"]*")', // cat="meow"
664+
'([a-zA-Z0-9\-_]+\=\'[^\']*\')', // mouse='squeak squeak'
665+
'([a-zA-Z0-9\-_]+\=[a-zA-Z0-9_\./]+)', // dog=false dog=./woof dog=.././woof
666+
'([a-zA-Z0-9\-_]+\=@[a-zA-Z0-9_]+)', // dog=@woof
665667
];
666668

667669
foreach ($stringArgs as $arg) {
668670
//if it's an attribute
669671
if (!(substr($arg, 0, 1) === "'" && substr($arg, -1) === "'")
670672
&& !(substr($arg, 0, 1) === '"' && substr($arg, -1) === '"')
671-
&& preg_match('#'.implode('|', $hashRegex).'#is', $arg)
673+
&& preg_match('#' . implode('|', $hashRegex) . '#is', $arg)
672674
) {
673675
list($hashKey, $hashValue) = explode('=', $arg, 2);
674676
$hash[$hashKey] = $this->parseArgument($hashValue);

0 commit comments

Comments
 (0)