From dfc76de86afc620d9eebf4d2f328cd92eed72105 Mon Sep 17 00:00:00 2001 From: Victor Shih Date: Sun, 12 May 2024 02:13:45 -0700 Subject: [PATCH] Handle non-string lambda results. --- src/Mustache/Template.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Mustache/Template.php b/src/Mustache/Template.php index 4de82393..4ffddbff 100644 --- a/src/Mustache/Template.php +++ b/src/Mustache/Template.php @@ -170,9 +170,15 @@ protected function prepareContextStack($context = null) protected function resolveValue($value, Mustache_Context $context) { if (($this->strictCallables ? is_object($value) : !is_string($value)) && is_callable($value)) { - return $this->mustache - ->loadLambda((string) call_user_func($value)) - ->renderInternal($context); + $result = call_user_func($value); + + if (is_string($result)) { + return $this->mustache + ->loadLambda($result) + ->renderInternal($context); + } else { + return $result; + } } return $value;