Skip to content

Commit

Permalink
Merge pull request #416 from vshih/fix/dotted-lambdas
Browse files Browse the repository at this point in the history
Handle non-string lambda results.
  • Loading branch information
bobthecow authored May 13, 2024
2 parents 8e99679 + dfc76de commit c7bcc12
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 c7bcc12

Please sign in to comment.