From b20a143e2d644a401b7759ec3e9a3079b0841db2 Mon Sep 17 00:00:00 2001 From: Veselin Vasilev Date: Sun, 10 Mar 2013 03:14:39 -0500 Subject: [PATCH 1/2] Fixes #7 --- src/Everzet/Jade/Lexer/Lexer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Everzet/Jade/Lexer/Lexer.php b/src/Everzet/Jade/Lexer/Lexer.php index 898d677..3d80b3c 100644 --- a/src/Everzet/Jade/Lexer/Lexer.php +++ b/src/Everzet/Jade/Lexer/Lexer.php @@ -308,12 +308,13 @@ protected function scanAttributes() $index = $this->getDelimitersIndex('(', ')'); $input = mb_substr($this->input, 1, $index - 1); $token = $this->takeToken('attributes', $input); - $attributes = preg_split('/ *, *(?=[\'"\w-]+ *[:=]|[\w-]+ *$)/', $token->value); + $attributes = preg_split('/ *(?value); $this->consumeInput($index + 1); $token->attributes = array(); foreach ($attributes as $i => $pair) { $pair = preg_replace('/^ *| *$/', '', $pair); + $pair = str_replace('\,', ',', $pair); $colon = mb_strpos($pair, ':'); $equal = mb_strpos($pair, '='); From 01cd4a1f140ae8ee3c46bdc73bf75c7b52e31567 Mon Sep 17 00:00:00 2001 From: Veselin Vasilev Date: Fri, 29 Mar 2013 20:20:44 -0500 Subject: [PATCH 2/2] Added test case for #7 fix --- tests/Everzet/Jade/JadeTest.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/Everzet/Jade/JadeTest.php b/tests/Everzet/Jade/JadeTest.php index babbbef..3412a4f 100644 --- a/tests/Everzet/Jade/JadeTest.php +++ b/tests/Everzet/Jade/JadeTest.php @@ -331,18 +331,18 @@ public function testAttrs() $this->assertEquals('

', $this->parse("p(\"class\": 'foo')"), 'Keys with double quotes'); -// $this->assertEquals( -// '', -// $this->parse( -// "meta(name: 'viewport', content:\"width=device-width, user-scalable=no\")" -// ), 'Commas in attrs' -// ); -// $this->assertEquals( -// '', -// $this->parse( -// "meta(name: 'viewport', content:'width=device-width, user-scalable=no')" -// ), 'Commas in attrs' -// ); + $this->assertEquals( + '', + $this->parse( + "meta(name: 'viewport', content:\"width=device-width\\, user-scalable=no\")" + ), 'Commas in attrs' + ); + $this->assertEquals( + '', + $this->parse( + "meta(name: 'viewport', content:'width=device-width\\, user-scalable=no')" + ), 'Commas in attrs' + ); } public function testCodeAttrs()