-
Notifications
You must be signed in to change notification settings - Fork 0
Graceful type handling #24
Copy link
Copy link
Open
Labels
Description
The following raise "array to string conversion" exceptions - should be handle them more gracefully?
diff --git a/src/test/php/com/handlebarsjs/unittest/EachHelperTest.class.php b/src/test/php/com/handlebarsjs/unittest/EachHelperTest.class.php
index 1b664b6..6a71db2 100755
--- a/src/test/php/com/handlebarsjs/unittest/EachHelperTest.class.php
+++ b/src/test/php/com/handlebarsjs/unittest/EachHelperTest.class.php
@@ -304,4 +304,12 @@ class EachHelperTest extends HelperTest {
['locations' => ['KA' => ['names' => ['de_DE' => 'Karlsruhe', 'de_BW' => 'Karlsruh']]]]
));
}
+
+ #[Test]
+ public function iterator_given_nested_array() {
+ Assert::equals('', $this->evaluate('{{#each names}}{{.}}{{/each}}', ['names' => [
+ [['en' => 'Hello', 'de' => 'Hallo']],
+ [['en' => 'World', 'de' => 'Welt']]
+ ]]));
+ }
}
\ No newline at end of file
diff --git a/src/test/php/com/handlebarsjs/unittest/ExecutionTest.class.php b/src/test/php/com/handlebarsjs/unittest/ExecutionTest.class.php
index 4493cab..6789a99 100755
--- a/src/test/php/com/handlebarsjs/unittest/ExecutionTest.class.php
+++ b/src/test/php/com/handlebarsjs/unittest/ExecutionTest.class.php
@@ -37,6 +37,11 @@ class ExecutionTest {
Assert::equals('', $this->evaluate('{{missing}}', []));
}
+ #[Test]
+ public function given_array() {
+ Assert::equals('', $this->evaluate('{{names}}', ['names' => ['Hello', 'World']]));
+ }
+
#[Test]
public function html_special_chars_are_escaped() {
Assert::equals('"<&>'"', $this->evaluate('{{name}}', ['name' => '"<&>\'"']));
Reactions are currently unavailable