From 8b685565e9ec01ce54eba3618b268f2a989864f8 Mon Sep 17 00:00:00 2001 From: Tam Date: Fri, 12 Feb 2021 15:00:19 +0000 Subject: [PATCH] Fix issue with hyphens in endx names --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/web/twig/tokenparsers/AtomTokenParser.php | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a56bda..74e3a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.2 - 2020-02-12 +### Fixed +- Fix issue with hyphens in endx names + ## 1.0.1 - 2020-02-12 ### Improved - Added self-closing tag support! diff --git a/composer.json b/composer.json index 3b67e3e..741423a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ether/atom", "description": "Adding enhanced modularity to Craft CMS Twig templating", - "version": "1.0.1", + "version": "1.0.2", "type": "craft-plugin", "license": "MIT", "minimum-stability": "dev", diff --git a/src/web/twig/tokenparsers/AtomTokenParser.php b/src/web/twig/tokenparsers/AtomTokenParser.php index 55738c2..4e33e87 100644 --- a/src/web/twig/tokenparsers/AtomTokenParser.php +++ b/src/web/twig/tokenparsers/AtomTokenParser.php @@ -94,7 +94,11 @@ public function parse (Token $token): Node $stream->expect(Token::PUNCTUATION_TYPE, ':'); $stream->nextIf(Token::PUNCTUATION_TYPE, '['); - $stream->expect(Token::NAME_TYPE, $strHandle); + foreach (preg_split('/(-)/', $strHandle, -1, PREG_SPLIT_DELIM_CAPTURE) as $word) + { + if ($word === '-') $stream->expect(Token::OPERATOR_TYPE, $word); + else $stream->expect(Token::NAME_TYPE, $word); + } $stream->nextIf(Token::PUNCTUATION_TYPE, ']'); }