From f3ae65eb33abe30f6206ed9609c8ad53f1dd43ff Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 14 Feb 2016 08:37:41 -0800 Subject: [PATCH] Fix incorrect indent on interpolated lambdas. Fixes #286 --- src/Mustache/Compiler.php | 2 +- src/Mustache/Template.php | 5 ++--- test/Mustache/Test/CompilerTest.php | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index dad5310..76e580c 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -498,7 +498,7 @@ class Mustache_Compiler } const VARIABLE = ' - $value = $this->resolveValue($context->%s(%s), $context, $indent);%s + $value = $this->resolveValue($context->%s(%s), $context);%s $buffer .= %s%s; '; diff --git a/src/Mustache/Template.php b/src/Mustache/Template.php index 91074c4..f2d198f 100644 --- a/src/Mustache/Template.php +++ b/src/Mustache/Template.php @@ -164,16 +164,15 @@ abstract class Mustache_Template * * @param mixed $value * @param Mustache_Context $context - * @param string $indent * * @return string */ - protected function resolveValue($value, Mustache_Context $context, $indent = '') + 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, $indent); + ->renderInternal($context); } return $value; diff --git a/test/Mustache/Test/CompilerTest.php b/test/Mustache/Test/CompilerTest.php index d981249..e11bd98 100644 --- a/test/Mustache/Test/CompilerTest.php +++ b/test/Mustache/Test/CompilerTest.php @@ -55,7 +55,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase 'ISO-8859-1', array( "\nclass Monkey extends Mustache_Template", - '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', + '$value = $this->resolveValue($context->find(\'name\'), $context);', '$buffer .= $indent . call_user_func($this->mustache->getEscape(), $value);', 'return $buffer;', ), @@ -75,7 +75,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase 'ISO-8859-1', array( "\nclass Monkey extends Mustache_Template", - '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', + '$value = $this->resolveValue($context->find(\'name\'), $context);', '$buffer .= $indent . htmlspecialchars($value, ' . ENT_COMPAT . ', \'ISO-8859-1\');', 'return $buffer;', ), @@ -95,7 +95,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase 'ISO-8859-1', array( "\nclass Monkey extends Mustache_Template", - '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', + '$value = $this->resolveValue($context->find(\'name\'), $context);', '$buffer .= $indent . htmlspecialchars($value, ' . ENT_QUOTES . ', \'ISO-8859-1\');', 'return $buffer;', ), @@ -122,9 +122,9 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase array( "\nclass Monkey extends Mustache_Template", "\$buffer .= \$indent . 'foo\n';", - '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', + '$value = $this->resolveValue($context->find(\'name\'), $context);', '$buffer .= htmlspecialchars($value, ' . ENT_COMPAT . ', \'UTF-8\');', - '$value = $this->resolveValue($context->last(), $context, $indent);', + '$value = $this->resolveValue($context->last(), $context);', '$buffer .= \'\\\'bar\\\'\';', 'return $buffer;', ),