Skip to content

Commit

Permalink
Handle non-string lambda results.
Browse files Browse the repository at this point in the history
  • Loading branch information
vshih authored and bobthecow committed May 13, 2024
1 parent 1423c75 commit 8cbda9e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Mustache/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8cbda9e

Please sign in to comment.