From 1d7e612ad84d2354328839d4a717cf97a92ecdd4 Mon Sep 17 00:00:00 2001 From: "F. Gabriel Gosselin" Date: Sat, 5 Mar 2011 23:35:31 -0500 Subject: [PATCH 01/12] Adding record of issues from Google Code --- README.markdown | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 README.markdown diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..c6c79f6 --- /dev/null +++ b/README.markdown @@ -0,0 +1,51 @@ +## Issues from the original Google Code repository + +### Resolved Issues +* [Issue 47](http://code.google.com/p/phamlp/issues/detail?id=47): Sass: Unitless function throws an error. [resolved](https://github.com/MarcWeber/phamlp/commit/aaeed17368f2fbc5b40716415e0a38f88c6b661a) +* [Issue 48](http://code.google.com/p/phamlp/issues/detail?id=48): Haml Proper Indenting? [resolved](https://github.com/MarcWeber/phamlp/commit/237b87f2b6f64bd5d6703790f9befa55a7226e6c) +* [Issue 52](http://code.google.com/p/phamlp/issues/detail?id=52): Processing of color components numeric overflowing [resolved](https://github.com/MarcWeber/phamlp/commit/79cc6a37f615a9cbe1dfe330bad11d5c94a4a081) +* [Issue 58](http://code.google.com/p/phamlp/issues/detail?id=58): sass and haml parsing error + +### Unresolved (added to GitHub issues) +* [Issue 58](http://code.google.com/p/phamlp/issues/detail?id=58): sass and haml parsing error + +### Backlog (unprocessed from Google code) +* [Issue 49](http://code.google.com/p/phamlp/issues/detail?id=49): Allow to not include any helper file +* [Issue 50](http://code.google.com/p/phamlp/issues/detail?id=50): Execution of php code after specified tag attributes +* [Issue 51](http://code.google.com/p/phamlp/issues/detail?id=51): no css generation with PHP 5.3.1 +* [Issue 53](http://code.google.com/p/phamlp/issues/detail?id=53): [Sass] Proper Attribution of Compass Source +* [Issue 54](http://code.google.com/p/phamlp/issues/detail?id=54): Invalid css output whe using @else if inside of mixin +* [Issue 55](http://code.google.com/p/phamlp/issues/detail?id=55): @media rules doesnt work in sass +* [Issue 56](http://code.google.com/p/phamlp/issues/detail?id=56): transparent is not a colour +* [Issue 57](http://code.google.com/p/phamlp/issues/detail?id=57): Indentation guess algorithm fails if there is a multiline comment at the top + +* [Issue 59](http://code.google.com/p/phamlp/issues/detail?id=59): sass mixin argument parsing error +* [Issue 60](http://code.google.com/p/phamlp/issues/detail?id=60): sass script processing order +* [Issue 61](http://code.google.com/p/phamlp/issues/detail?id=61): Yii Ext: Docs code for Sass +* [Issue 62](http://code.google.com/p/phamlp/issues/detail?id=62): Demo files for Yii Framework not up to date +* [Issue 63](http://code.google.com/p/phamlp/issues/detail?id=63): Yii specific phamlp extension: consider moving vendors folder +* [Issue 64](http://code.google.com/p/phamlp/issues/detail?id=64): Example SCSS code on the Project Home page is incorrect. +* [Issue 65](http://code.google.com/p/phamlp/issues/detail?id=65): Haml helper function list_of return empty +* [Issue 66](http://code.google.com/p/phamlp/issues/detail?id=66): Exception while throwing SassPropertyNodeException in SassPropertyNode::isa() +* [Issue 67](http://code.google.com/p/phamlp/issues/detail?id=67): Extension could not be found +* [Issue 68](http://code.google.com/p/phamlp/issues/detail?id=68): Extensions parameter is missing in sass.php (CakePHP version) +* [Issue 69](http://code.google.com/p/phamlp/issues/detail?id=69): Some function of Sass are failing +* [Issue 70](http://code.google.com/p/phamlp/issues/detail?id=70): Sass : parsing fails with :: and = +* [Issue 71](http://code.google.com/p/phamlp/issues/detail?id=71): vendor properties are not correctly merged +* [Issue 72](http://code.google.com/p/phamlp/issues/detail?id=72): SASS function alias 'color_stops' broken +* [Issue 73](http://code.google.com/p/phamlp/issues/detail?id=73): Fix webkit gradient with color-stop +* [Issue 74](http://code.google.com/p/phamlp/issues/detail?id=74): SassNestedRenderer: Missing argument, caused by SassNestedRenderer +* [Issue 75](http://code.google.com/p/phamlp/issues/detail?id=75): Function font_files has incorrect brackets +* [Issue 76](http://code.google.com/p/phamlp/issues/detail?id=76): SASS mixin font-face produces wrong css +* [Issue 77](http://code.google.com/p/phamlp/issues/detail?id=77): Mixin::opacity: Required variable (opacity) not given +* [Issue 78](http://code.google.com/p/phamlp/issues/detail?id=78): wrong darken value +* [Issue 79](http://code.google.com/p/phamlp/issues/detail?id=79): add support CSS3 PIE +* [Issue 80](http://code.google.com/p/phamlp/issues/detail?id=80): extend selector with nesting +* [Issue 81](http://code.google.com/p/phamlp/issues/detail?id=81): No documentation on how to use Compass +* [Issue 82](http://code.google.com/p/phamlp/issues/detail?id=82): sass assets for CakePHP does not support plugins +* [Issue 83](http://code.google.com/p/phamlp/issues/detail?id=83): No Exception thrown when compiling scss files +* [Issue 84](http://code.google.com/p/phamlp/issues/detail?id=84): Warning: dirname() expects parameter 1 to be string, array given in /var/www/domains/sinwolf.com/www/cms/application/classes/packager/plugins/phamlp/sass/SassFile.php on line 79 +* [Issue 85](http://code.google.com/p/phamlp/issues/detail?id=85): This project is dead, don't bother post issue +* [Issue 86](http://code.google.com/p/phamlp/issues/detail?id=86): != &= implementation is missing +* [Issue 87](http://code.google.com/p/phamlp/issues/detail?id=87): Haml - Escaping differs from original haml +* [Issue 88](http://code.google.com/p/phamlp/issues/detail?id=88): Haml - allows nesting that original haml does not From 0b65c3641e39d11e19e6990e0bc6bda21c47f373 Mon Sep 17 00:00:00 2001 From: "F. Gabriel Gosselin" Date: Sat, 5 Mar 2011 23:55:26 -0500 Subject: [PATCH 02/12] Logged all recognizable issues as resolved --- README.markdown | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index c6c79f6..ae93be5 100644 --- a/README.markdown +++ b/README.markdown @@ -1,13 +1,23 @@ ## Issues from the original Google Code repository +Since the original Google Code project seems abandoned, this is an attempt to get a current status of pending issues. ### Resolved Issues * [Issue 47](http://code.google.com/p/phamlp/issues/detail?id=47): Sass: Unitless function throws an error. [resolved](https://github.com/MarcWeber/phamlp/commit/aaeed17368f2fbc5b40716415e0a38f88c6b661a) * [Issue 48](http://code.google.com/p/phamlp/issues/detail?id=48): Haml Proper Indenting? [resolved](https://github.com/MarcWeber/phamlp/commit/237b87f2b6f64bd5d6703790f9befa55a7226e6c) * [Issue 52](http://code.google.com/p/phamlp/issues/detail?id=52): Processing of color components numeric overflowing [resolved](https://github.com/MarcWeber/phamlp/commit/79cc6a37f615a9cbe1dfe330bad11d5c94a4a081) -* [Issue 58](http://code.google.com/p/phamlp/issues/detail?id=58): sass and haml parsing error +* [Issue 58](http://code.google.com/p/phamlp/issues/detail?id=58): sass and haml parsing error [partially resolved](https://github.com/MarcWeber/phamlp/commit/0758bed56f447f50d08f595e988ca866d9caa7f2) see issue MarcWeber/phamlp#1 +* [Issue 59](http://code.google.com/p/phamlp/issues/detail?id=59): sass mixin argument parsing error [resolved](https://github.com/MarcWeber/phamlp/commit/be5c769002bdf0d54b039aca3a2b55ab84a7fbef) +* [Issue 69](http://code.google.com/p/phamlp/issues/detail?id=69): Some function of Sass are failing [resolved](https://github.com/MarcWeber/phamlp/commit/331f0b7ccebc914a9de512d79a145376a9165a1a) +* [Issue 71](http://code.google.com/p/phamlp/issues/detail?id=71): vendor properties are not correctly merged [resolved](https://github.com/MarcWeber/phamlp/commit/64bc4e076a5100608a5e05d1903a96a0a3059639) +* [Issue 72](http://code.google.com/p/phamlp/issues/detail?id=72): SASS function alias 'color_stops' broken [resolved](https://github.com/MarcWeber/phamlp/commit/02b6e235117af0551089606a6fd8747ed472191b) +* [Issue 73](http://code.google.com/p/phamlp/issues/detail?id=73): Fix webkit gradient with color-stop [resolved](https://github.com/MarcWeber/phamlp/commit/64580bf819d895b10e5cc9fe6d3033c2335670f5) +* [Issue 74](http://code.google.com/p/phamlp/issues/detail?id=74): SassNestedRenderer: Missing argument, caused by SassNestedRenderer [resolved](https://github.com/MarcWeber/phamlp/commit/bf1408462be7dec6885b9a7dfe666b66f4f6a0df) +* [Issue 75](http://code.google.com/p/phamlp/issues/detail?id=75): Function font_files has incorrect brackets [resolved](https://github.com/MarcWeber/phamlp/commit/e271c2dd018dad0dfa25fa8f41b7a9b1b455abe8) +* [Issue 78](http://code.google.com/p/phamlp/issues/detail?id=78): wrong darken value [resolved](https://github.com/MarcWeber/phamlp/commit/43032beaf0d892ecfc4fd08742ca26817fbaa226) + ### Unresolved (added to GitHub issues) -* [Issue 58](http://code.google.com/p/phamlp/issues/detail?id=58): sass and haml parsing error +* [Issue 58](http://code.google.com/p/phamlp/issues/detail?id=58): sass and haml parsing error [new issue](https://github.com/MarcWeber/phamlp/issues#issue/1) ### Backlog (unprocessed from Google code) * [Issue 49](http://code.google.com/p/phamlp/issues/detail?id=49): Allow to not include any helper file @@ -18,8 +28,6 @@ * [Issue 55](http://code.google.com/p/phamlp/issues/detail?id=55): @media rules doesnt work in sass * [Issue 56](http://code.google.com/p/phamlp/issues/detail?id=56): transparent is not a colour * [Issue 57](http://code.google.com/p/phamlp/issues/detail?id=57): Indentation guess algorithm fails if there is a multiline comment at the top - -* [Issue 59](http://code.google.com/p/phamlp/issues/detail?id=59): sass mixin argument parsing error * [Issue 60](http://code.google.com/p/phamlp/issues/detail?id=60): sass script processing order * [Issue 61](http://code.google.com/p/phamlp/issues/detail?id=61): Yii Ext: Docs code for Sass * [Issue 62](http://code.google.com/p/phamlp/issues/detail?id=62): Demo files for Yii Framework not up to date @@ -29,16 +37,9 @@ * [Issue 66](http://code.google.com/p/phamlp/issues/detail?id=66): Exception while throwing SassPropertyNodeException in SassPropertyNode::isa() * [Issue 67](http://code.google.com/p/phamlp/issues/detail?id=67): Extension could not be found * [Issue 68](http://code.google.com/p/phamlp/issues/detail?id=68): Extensions parameter is missing in sass.php (CakePHP version) -* [Issue 69](http://code.google.com/p/phamlp/issues/detail?id=69): Some function of Sass are failing * [Issue 70](http://code.google.com/p/phamlp/issues/detail?id=70): Sass : parsing fails with :: and = -* [Issue 71](http://code.google.com/p/phamlp/issues/detail?id=71): vendor properties are not correctly merged -* [Issue 72](http://code.google.com/p/phamlp/issues/detail?id=72): SASS function alias 'color_stops' broken -* [Issue 73](http://code.google.com/p/phamlp/issues/detail?id=73): Fix webkit gradient with color-stop -* [Issue 74](http://code.google.com/p/phamlp/issues/detail?id=74): SassNestedRenderer: Missing argument, caused by SassNestedRenderer -* [Issue 75](http://code.google.com/p/phamlp/issues/detail?id=75): Function font_files has incorrect brackets * [Issue 76](http://code.google.com/p/phamlp/issues/detail?id=76): SASS mixin font-face produces wrong css * [Issue 77](http://code.google.com/p/phamlp/issues/detail?id=77): Mixin::opacity: Required variable (opacity) not given -* [Issue 78](http://code.google.com/p/phamlp/issues/detail?id=78): wrong darken value * [Issue 79](http://code.google.com/p/phamlp/issues/detail?id=79): add support CSS3 PIE * [Issue 80](http://code.google.com/p/phamlp/issues/detail?id=80): extend selector with nesting * [Issue 81](http://code.google.com/p/phamlp/issues/detail?id=81): No documentation on how to use Compass From 5809d15b8c903771e5ad50c071364b1d87132334 Mon Sep 17 00:00:00 2001 From: "F. Gabriel Gosselin" Date: Sun, 6 Mar 2011 00:12:47 -0500 Subject: [PATCH 03/12] Logging more resolved issues --- README.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index ae93be5..381b906 100644 --- a/README.markdown +++ b/README.markdown @@ -14,6 +14,7 @@ Since the original Google Code project seems abandoned, this is an attempt to ge * [Issue 74](http://code.google.com/p/phamlp/issues/detail?id=74): SassNestedRenderer: Missing argument, caused by SassNestedRenderer [resolved](https://github.com/MarcWeber/phamlp/commit/bf1408462be7dec6885b9a7dfe666b66f4f6a0df) * [Issue 75](http://code.google.com/p/phamlp/issues/detail?id=75): Function font_files has incorrect brackets [resolved](https://github.com/MarcWeber/phamlp/commit/e271c2dd018dad0dfa25fa8f41b7a9b1b455abe8) * [Issue 78](http://code.google.com/p/phamlp/issues/detail?id=78): wrong darken value [resolved](https://github.com/MarcWeber/phamlp/commit/43032beaf0d892ecfc4fd08742ca26817fbaa226) +* [Issue 86](http://code.google.com/p/phamlp/issues/detail?id=86): != &= implementation is missing [resolved](https://github.com/MarcWeber/phamlp/commit/2b0ce57083cabd4b621a45e96e012bfe728ca229) ### Unresolved (added to GitHub issues) @@ -46,7 +47,5 @@ Since the original Google Code project seems abandoned, this is an attempt to ge * [Issue 82](http://code.google.com/p/phamlp/issues/detail?id=82): sass assets for CakePHP does not support plugins * [Issue 83](http://code.google.com/p/phamlp/issues/detail?id=83): No Exception thrown when compiling scss files * [Issue 84](http://code.google.com/p/phamlp/issues/detail?id=84): Warning: dirname() expects parameter 1 to be string, array given in /var/www/domains/sinwolf.com/www/cms/application/classes/packager/plugins/phamlp/sass/SassFile.php on line 79 -* [Issue 85](http://code.google.com/p/phamlp/issues/detail?id=85): This project is dead, don't bother post issue -* [Issue 86](http://code.google.com/p/phamlp/issues/detail?id=86): != &= implementation is missing * [Issue 87](http://code.google.com/p/phamlp/issues/detail?id=87): Haml - Escaping differs from original haml * [Issue 88](http://code.google.com/p/phamlp/issues/detail?id=88): Haml - allows nesting that original haml does not From 0e3b3eb2388dc6c59411fa29e59970adea822c26 Mon Sep 17 00:00:00 2001 From: Goncalo Esteves Date: Mon, 28 Feb 2011 23:11:58 +0800 Subject: [PATCH 04/12] add folder to .gitignore for phpstorm editor --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e6d0fb1..ddf9658 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/sass/sass-cache \ No newline at end of file +/sass/sass-cache +.idea \ No newline at end of file From 12168324dfd9eb96a84c657db34f0b321d560edb Mon Sep 17 00:00:00 2001 From: Goncalo Esteves Date: Mon, 28 Feb 2011 23:12:39 +0800 Subject: [PATCH 05/12] add test3.php for issue 80 --- tests/test3.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/test3.php diff --git a/tests/test3.php b/tests/test3.php new file mode 100644 index 0000000..22dcd9a --- /dev/null +++ b/tests/test3.php @@ -0,0 +1,24 @@ +'.$sass->toCss($source, false).''; \ No newline at end of file From 74b92df122647dab0504b27de1763cae3f809d4a Mon Sep 17 00:00:00 2001 From: Goncalo Esteves Date: Tue, 1 Mar 2011 08:14:52 +0800 Subject: [PATCH 06/12] add test4 for if conditions --- tests/test4.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test4.php diff --git a/tests/test4.php b/tests/test4.php new file mode 100644 index 0000000..bd00043 --- /dev/null +++ b/tests/test4.php @@ -0,0 +1,20 @@ +'.$sass->toCss($source, false).''; \ No newline at end of file From c0824eaeacccb6b67dc65eaa4c1825a20b41da76 Mon Sep 17 00:00:00 2001 From: Goncalo Esteves Date: Tue, 1 Mar 2011 08:17:35 +0800 Subject: [PATCH 07/12] fixed bug in parse of if/else nodes --- sass/tree/SassIfNode.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sass/tree/SassIfNode.php b/sass/tree/SassIfNode.php index 049c598..47e25c2 100644 --- a/sass/tree/SassIfNode.php +++ b/sass/tree/SassIfNode.php @@ -22,6 +22,10 @@ class SassIfNode extends SassNode { const IF_EXPRESSION = 1; const ELSE_IF = 1; const ELSE_EXPRESSION = 2; + /** + * @var boolean if node is if. + */ + private $isif; /** * @var SassIfNode the next else node. */ @@ -42,10 +46,12 @@ public function __construct($token, $if=true) { if ($if) { preg_match(self::MATCH_IF, $token->source, $matches); $this->expression = $matches[SassIfNode::IF_EXPRESSION]; + $this->isif = true; } else { preg_match(self::MATCH_ELSE, $token->source, $matches); $this->expression = (sizeof($matches)==1 ? null : $matches[SassIfNode::ELSE_EXPRESSION]); + $this->isif = false; } } @@ -90,6 +96,6 @@ public function parse($context) { * or "else if" node */ private function isElse() { - return empty($this->expression); + return !$this->isif; } } \ No newline at end of file From a679c6830b6222c741f858d4fee2dbf0dfe26096 Mon Sep 17 00:00:00 2001 From: Goncalo Esteves Date: Tue, 1 Mar 2011 08:20:08 +0800 Subject: [PATCH 08/12] fixed bug when condition in if node is a color --- sass/script/literals/SassLiteral.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass/script/literals/SassLiteral.php b/sass/script/literals/SassLiteral.php index d0153aa..c19a64c 100644 --- a/sass/script/literals/SassLiteral.php +++ b/sass/script/literals/SassLiteral.php @@ -69,7 +69,7 @@ public function __toString() { * @return boolean the boolean representation of the value of this */ public function toBoolean() { - return (boolean)$this->value; + return (boolean)$this->value||$this->value===null; } /** From 7c81a7a1792a2c0b651364db7c526d3fa005da5e Mon Sep 17 00:00:00 2001 From: Goncalo Esteves Date: Tue, 1 Mar 2011 08:38:38 +0800 Subject: [PATCH 09/12] Revert "fixed bug in parse of if/else nodes" This reverts commit 7a129fbfe329859f3b503e3a817d7fffcf2e5555. --- sass/tree/SassIfNode.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sass/tree/SassIfNode.php b/sass/tree/SassIfNode.php index 47e25c2..cd9d03b 100644 --- a/sass/tree/SassIfNode.php +++ b/sass/tree/SassIfNode.php @@ -22,10 +22,6 @@ class SassIfNode extends SassNode { const IF_EXPRESSION = 1; const ELSE_IF = 1; const ELSE_EXPRESSION = 2; - /** - * @var boolean if node is if. - */ - private $isif; /** * @var SassIfNode the next else node. */ @@ -46,12 +42,10 @@ public function __construct($token, $if=true) { if ($if) { preg_match(self::MATCH_IF, $token->source, $matches); $this->expression = $matches[SassIfNode::IF_EXPRESSION]; - $this->isif = true; } else { preg_match(self::MATCH_ELSE, $token->source, $matches); $this->expression = (sizeof($matches)==1 ? null : $matches[SassIfNode::ELSE_EXPRESSION]); - $this->isif = false; } } @@ -96,6 +90,6 @@ public function parse($context) { * or "else if" node */ private function isElse() { - return !$this->isif; + return ($this->expression==''); } } \ No newline at end of file From 7c66d9995eca57a8c6bdf290c7b7f1385d2b473a Mon Sep 17 00:00:00 2001 From: "F. Gabriel Gosselin" Date: Sun, 6 Mar 2011 00:52:50 -0500 Subject: [PATCH 10/12] Applying patch from http://code.google.com/p/phamlp/issues/detail?id=58 --- haml/HamlParser.php | 1 + 1 file changed, 1 insertion(+) diff --git a/haml/HamlParser.php b/haml/HamlParser.php index 38e0901..963a3eb 100644 --- a/haml/HamlParser.php +++ b/haml/HamlParser.php @@ -447,6 +447,7 @@ public function haml2PHP($sourceFile) { * @return HamlRootNode the root of this document tree */ private function toTree($source) { + $source = str_replace(array("\r\n", "\n\r", "\r"), "\n", $source); $this->source = explode("\n", $source); $this->setIndentChar(); From 1d44121ac62a0f157dd1a127405421c8b56c2997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matyas?= Date: Mon, 7 Mar 2011 19:00:22 +0100 Subject: [PATCH 11/12] Added fixes for Sass to be working in PHP 5.3 --- sass/SassParser.php | 2 +- sass/script/literals/SassLiteral.php | 3 ++- sass/tree/SassPropertyNode.php | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/sass/SassParser.php b/sass/SassParser.php index 880ded7..03060f6 100644 --- a/sass/SassParser.php +++ b/sass/SassParser.php @@ -540,7 +540,7 @@ private function getNode($node) { case SassVariableNode::isa($token): return new SassVariableNode($token); break; - case SassPropertyNode::isa($token, $this->property_syntax): + case SassPropertyNode::isa(array('token' => $token, 'syntax' => $this->property_syntax)): return new SassPropertyNode($token, $this->property_syntax); break; case SassMixinDefinitionNode::isa($token): diff --git a/sass/script/literals/SassLiteral.php b/sass/script/literals/SassLiteral.php index c19a64c..0efab18 100644 --- a/sass/script/literals/SassLiteral.php +++ b/sass/script/literals/SassLiteral.php @@ -359,5 +359,6 @@ abstract public function toString(); * @param string the subject string * @return mixed match at the start of the string or false if no match */ - abstract public static function isa($subject); + // Static function SassLiteral::isa() should not be abstract + // abstract public static function isa($subject); } diff --git a/sass/tree/SassPropertyNode.php b/sass/tree/SassPropertyNode.php index 4201498..c1262ed 100644 --- a/sass/tree/SassPropertyNode.php +++ b/sass/tree/SassPropertyNode.php @@ -1,5 +1,5 @@ @@ -95,7 +95,7 @@ public function __construct($token, $syntax = 'new') { */ public function parse($context) { $return = array(); - if ($this->value!=="") { + if ($this->value !== "") { $node = clone $this; $node->name = ($this->inNamespace() ? "{$this->namespace}-" : '') . $this->interpolate($this->name, $context); @@ -177,7 +177,18 @@ public function getValue() { * @param string the property syntax being used * @return boolean true if the token represents this type of node, false if not */ - public static function isa($token, $syntax) { + public static function isa($token) { + + if(!is_array($token)) + { + $syntax = 'old'; + } + else + { + $syntax = $token['syntax']; + $token = $token['token']; + } + $matches = self::match($token, $syntax); if (!empty($matches)) { @@ -236,4 +247,4 @@ private static function isPseudoSelector($string) { return (isset($matches[0]) && in_array($matches[0], self::$psuedoSelectors)) || preg_match(self::MATCH_INTERPOLATION, $string); } -} \ No newline at end of file +} From 9b5894105a93eccb8fefb5b372394e45ed18df8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matyas?= Date: Mon, 7 Mar 2011 19:21:39 +0100 Subject: [PATCH 12/12] proper minimizedAttributes support (name="name" will render correctly, checked="#{$checked}" will not be rendered if $checked is empty string or null) --- haml/HamlParser.php | 6 +++--- haml/renderers/HamlRenderer.php | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/haml/HamlParser.php b/haml/HamlParser.php index 963a3eb..ba4bc60 100644 --- a/haml/HamlParser.php +++ b/haml/HamlParser.php @@ -951,7 +951,7 @@ private function parseAttributeHash($subject) { $attributes[$attr[3]] = ''; } elseif (!empty($attr[6])) { - $attributes[$attr[3]] = $this->interpolate($attr[6]); + $attributes[$attr[3]] = $this->interpolate($attr[6], $attr[3]); } elseif ($attr[6] === '') { $attributes[$attr[3]] = $attr[6]; @@ -1257,7 +1257,7 @@ private function parseWhitespaceControl($line) { * @param string the text to interpolate * @return string the interpolated text */ - protected function interpolate($string) { - return preg_replace(self::MATCH_INTERPOLATION, self::INTERPOLATE, $string); + protected function interpolate($string, $type = '') { + return preg_replace(self::MATCH_INTERPOLATION, (in_array($type, $this->minimizedAttributes) ? '\1' : self::INTERPOLATE), $string); } } diff --git a/haml/renderers/HamlRenderer.php b/haml/renderers/HamlRenderer.php index d7dc3be..3ce06fe 100644 --- a/haml/renderers/HamlRenderer.php +++ b/haml/renderers/HamlRenderer.php @@ -1,5 +1,5 @@ @@ -70,11 +70,26 @@ private function renderAttributes($attributes) { if (is_integer($name)) { // attribute function $output .= " $value"; } - elseif ($name == $value && + elseif ($name == $value && in_array($name, $this->minimizedAttributes) && ($this->format === 'html4' || $this->format === 'html5')) { $output .= " $name"; } - else { + elseif(in_array($name, $this->minimizedAttributes)) + { + // $value is a variable, isset is called to make sure E_NOTICE is not thrown + if(preg_match("/^\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", trim($value))) + { + $output .= "<"."?php if(isset($value) && !empty($value)): ?"."> $name={$this->attrWrapper}<"."?php echo $value; ?".">{$this->attrWrapper};<"."?php endif; ?".">"; + } + + // $value is either a method, a constant or a ternary operator + else + { + $output .= "<"."?php if($value): ?"."> $name={$this->attrWrapper}<"."?php echo $value; ?".">{$this->attrWrapper};<"."?php endif; ?".">"; + } + } + else + { $output .= " $name={$this->attrWrapper}$value{$this->attrWrapper}"; } } @@ -134,4 +149,4 @@ public function renderEndCodeBlock($node) { public function renderContent($node) { return $node->content; } -} \ No newline at end of file +}