From f9c9db7cb04828ddd85892a73483fb94abcc168a Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sat, 28 Oct 2023 11:02:23 +0200 Subject: [PATCH] Fix com.handlebarsjs.PartialNode string representation --- ChangeLog.md | 4 ++++ src/main/php/com/handlebarsjs/PartialNode.class.php | 2 +- .../com/handlebarsjs/unittest/PartialNodeTest.class.php | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2541d08..6b06eb4 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,10 @@ HandleBars change log ## ?.?.? / ????-??-?? +* Fixed `com.handlebarsjs.PartialNode` string representation to include + closing braces + (@thekid) + ## 9.2.0 / 2013-10-22 * Added support for literals enclosed in `[]` - @thekid diff --git a/src/main/php/com/handlebarsjs/PartialNode.class.php b/src/main/php/com/handlebarsjs/PartialNode.class.php index 7762aef..3cfbd8a 100755 --- a/src/main/php/com/handlebarsjs/PartialNode.class.php +++ b/src/main/php/com/handlebarsjs/PartialNode.class.php @@ -64,7 +64,7 @@ protected function optionString() { * @return string */ public function toString() { - return nameof($this).'{{> '.$this->template->toString().$this->optionString().'}}, indent= "'.$this->indent.'"'; + return nameof($this).'(> '.$this->template->toString().$this->optionString().'}}, indent= "'.$this->indent.'")'; } /** diff --git a/src/test/php/com/handlebarsjs/unittest/PartialNodeTest.class.php b/src/test/php/com/handlebarsjs/unittest/PartialNodeTest.class.php index c16ec90..e76c58c 100755 --- a/src/test/php/com/handlebarsjs/unittest/PartialNodeTest.class.php +++ b/src/test/php/com/handlebarsjs/unittest/PartialNodeTest.class.php @@ -14,13 +14,14 @@ public function template() { #[Test] public function string_representation() { - $partial= new PartialNode(new Lookup('test')); - Assert::equals('com.handlebarsjs.PartialNode{{> com.handlebarsjs.Lookup(test)}}, indent= ""', $partial->toString()); + Assert::equals( + 'com.handlebarsjs.PartialNode(> com.handlebarsjs.Lookup(test)}}, indent= "")', + (new PartialNode(new Lookup('test')))->toString() + ); } #[Test] public function string_cast() { - $partial= new PartialNode(new Lookup('test')); - Assert::equals('{{> test}}', (string)$partial); + Assert::equals('{{> test}}', (string)new PartialNode(new Lookup('test'))); } } \ No newline at end of file