Pass a helper to section lambdas

This commit is contained in:
Justin Hileman
2012-07-23 11:56:23 -07:00
parent 9e436f8c07
commit 52c7ccf1b9
3 changed files with 89 additions and 1 deletions
@@ -0,0 +1,37 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* @group lambdas
* @group functional
*/
class Mustache_Test_FiveThree_Functional_LambdaHelperTest extends PHPUnit_Framework_TestCase {
private $mustache;
public function setUp() {
$this->mustache = new Mustache_Engine;
}
public function testSectionLambdaHelper() {
$one = $this->mustache->loadTemplate('{{name}}');
$two = $this->mustache->loadTemplate('{{#lambda}}{{name}}{{/lambda}}');
$foo = new StdClass;
$foo->name = 'Mario';
$foo->lambda = function($text, $mustache) {
return strtoupper($mustache->render($text));
};
$this->assertEquals('Mario', $one->render($foo));
$this->assertEquals('MARIO', $two->render($foo));
}
}