Add resolveValue method to base Template.

DRYs up compiled class output a bit and makes things FASTER!

Speeds up value resolution by 33% for primitives, 25% for methods and properties, and 10% for lambdas.
This commit is contained in:
Justin Hileman
2013-01-26 16:19:06 -08:00
parent cf76a4b8f9
commit a777c587f2
3 changed files with 25 additions and 8 deletions
+2 -2
View File
@@ -70,9 +70,9 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
"\nclass Monkey extends Mustache_Template",
'$buffer .= $indent . \'foo\'',
'$buffer .= "\n"',
'$value = $context->find(\'name\');',
'$value = $this->resolveValue($context->find(\'name\'), $context, $indent);',
'$buffer .= htmlspecialchars($value, ENT_COMPAT, \'UTF-8\');',
'$value = $context->last();',
'$value = $this->resolveValue($context->last(), $context, $indent);',
'$buffer .= \'\\\'bar\\\'\';',
'return $buffer;',
)