Skip to content

Commit

Permalink
Fix com.handlebarsjs.PartialNode string representation
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 28, 2023
1 parent 3438780 commit f9c9db7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/com/handlebarsjs/PartialNode.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'")';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
}
}

0 comments on commit f9c9db7

Please sign in to comment.