Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Everzet/Jade/Lexer/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('/ *(?<!\\\\), *(?=[\'"\w-]+ *[:=]|[\w-]+ *$)/', $token->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, '=');

Expand Down
24 changes: 12 additions & 12 deletions tests/Everzet/Jade/JadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,18 @@ public function testAttrs()
$this->assertEquals('<p class="foo"></p>',
$this->parse("p(\"class\": 'foo')"), 'Keys with double quotes');

// $this->assertEquals(
// '<meta name="viewport" content="width=device-width, user-scalable=no" />',
// $this->parse(
// "meta(name: 'viewport', content:\"width=device-width, user-scalable=no\")"
// ), 'Commas in attrs'
// );
// $this->assertEquals(
// '<meta name="viewport" content="width=device-width, user-scalable=no" />',
// $this->parse(
// "meta(name: 'viewport', content:'width=device-width, user-scalable=no')"
// ), 'Commas in attrs'
// );
$this->assertEquals(
'<meta name="viewport" content="width=device-width, user-scalable=no" />',
$this->parse(
"meta(name: 'viewport', content:\"width=device-width\\, user-scalable=no\")"
), 'Commas in attrs'
);
$this->assertEquals(
'<meta name="viewport" content="width=device-width, user-scalable=no" />',
$this->parse(
"meta(name: 'viewport', content:'width=device-width\\, user-scalable=no')"
), 'Commas in attrs'
);
}

public function testCodeAttrs()
Expand Down