Merge branch 'subexpr_context_test' of github.com:Mibew/handlebars.php

This commit is contained in:
fzerorubigd 2014-08-29 11:21:17 +04:30
commit 1b491bf602

View File

@ -951,6 +951,21 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase
// assert that bracketed expressions within string literals are treated correctly
$this->assertEquals("'(test)'Test.", $engine->render("{{test '(test)'}}", array()));
$this->assertEquals("')'Test.Test.", $engine->render("{{test (test ')')}}", array()));
$engine->addHelper('concat', function($template, $context, $args) {
$result = '';
foreach($template->parseArguments($args) as $arg) {
$result .= $context->get($arg);
}
return $result;
});
$this->assertEquals('ACB', $engine->render('{{concat a (concat c b)}}', array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$this->assertEquals('ACB', $engine->render('{{concat (concat a c) b}}', array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$this->assertEquals('A-B', $engine->render('{{concat (concat a "-") b}}', array('a' => 'A', 'b' => 'B')));
$this->assertEquals('A-B', $engine->render('{{concat (concat a "-") b}}', array('a' => 'A', 'b' => 'B', 'A-' => '!')));
}
/**