Make LambdaHelper invokable.

Fixes #285
This commit is contained in:
Justin Hileman
2016-02-14 08:43:38 -08:00
parent 3c53736f09
commit 865de4114a
2 changed files with 27 additions and 0 deletions
@@ -49,4 +49,19 @@ class Mustache_Test_FiveThree_Functional_LambdaHelperTest extends PHPUnit_Framew
$this->assertEquals('hello world!', $tpl->render($data));
}
public function testLambdaHelperIsInvokable()
{
$one = $this->mustache->loadTemplate('{{name}}');
$two = $this->mustache->loadTemplate('{{#lambda}}{{name}}{{/lambda}}');
$foo = new StdClass();
$foo->name = 'Mario';
$foo->lambda = function ($text, $render) {
return strtoupper($render($text));
};
$this->assertEquals('Mario', $one->render($foo));
$this->assertEquals('MARIO', $two->render($foo));
}
}