From c749883e36ea6807824d7a2829cdcc02b11d49ad Mon Sep 17 00:00:00 2001 From: webuser Date: Sun, 2 Feb 2014 23:47:52 -0500 Subject: [PATCH 1/3] parse HTML style attributes and values --- src/Handlebars/Template.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Handlebars/Template.php b/src/Handlebars/Template.php index d88165b..34e2b94 100644 --- a/src/Handlebars/Template.php +++ b/src/Handlebars/Template.php @@ -472,4 +472,33 @@ public function parseArguments($string) } return $args; } + + /** + * Break an argument string of HTML attribute/values into an array of key value pairs + * + * @param string $string Argument String as passed to a helper + * + * @return array the argument list as an array + */ + public funcion parseTagAttributes ($string) + { + $attributes = []; + $pattern = '#(?(DEFINE) + (?[a-zA-Z][a-zA-Z0-9-:]*) + (?"[^"]+") + (?\'[^\']+\') + (?[^\s>]+) + (?((?&value_double)|(?&value_single)|(?&value_none))) + ) + (?(?&name))(=(?(?&value)))?#xs'; + + if (preg_match_all($pattern, $string, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $attributes[$match['n']] = isset($match['v']) + ? trim($match['v'], '\'"') + : null; + } + } + return $attributes; + } } From 7fdaf511159d7bc658dc68133e93f35f4cc4cfa5 Mon Sep 17 00:00:00 2001 From: webuser Date: Sun, 2 Feb 2014 23:53:10 -0500 Subject: [PATCH 2/3] typo --- src/Handlebars/Template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handlebars/Template.php b/src/Handlebars/Template.php index 34e2b94..f2515a6 100644 --- a/src/Handlebars/Template.php +++ b/src/Handlebars/Template.php @@ -480,7 +480,7 @@ public function parseArguments($string) * * @return array the argument list as an array */ - public funcion parseTagAttributes ($string) + public function parseTagAttributes ($string) { $attributes = []; $pattern = '#(?(DEFINE) From 534990a7a0401c8b9c307f81ee7f1f0c85feb821 Mon Sep 17 00:00:00 2001 From: webuser Date: Mon, 3 Feb 2014 00:02:40 -0500 Subject: [PATCH 3/3] update composer --- composer.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index f8afb8f..e566ae3 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "xamin/handlebars.php", + "name": "opine/handlebars.php", "description": "Handlebars processor for php", "homepage": "https://github.com/XaminProject/handlebars.php", "type": "library", @@ -16,9 +16,7 @@ "email": "everplays@gmail.com" } ], - "require": { - - }, + "require": {}, "require-dev": { "phpunit/phpunit": "3.7.*", "squizlabs/php_codesniffer": "1.*"