This commit is contained in:
bzick 2015-05-23 23:09:16 +03:00
parent 9269b6b4ad
commit 806467453d
3 changed files with 12 additions and 3 deletions

View File

@ -7,6 +7,6 @@ require_once __DIR__.'/../tests/tools.php';
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled');
$fenom->setOptions(Fenom::AUTO_RELOAD);
var_dump($fenom->compileCode('{$b == 5 ? "5" : "?"}')->getBody());
var_dump($fenom->compileCode('{set $z = "A"~~"B"}')->getBody());
//$fenom->display("blocks/second.tpl", []);
// $fenom->getTemplate("problem.tpl");

View File

@ -734,13 +734,15 @@ class Template extends Render
if ($tokens->is(T_LNUMBER, T_DNUMBER)) {
$concat[] = "strval(" . $this->parseTerm($tokens) . ")";
} else {
if ($tokens->is('~')) {
$tokens->next();
$concat[] = " ";
$concat[] = "' '";
}
if (!$concat[] = $this->parseTerm($tokens)) {
if (!$term2 = "strval(".$this->parseTerm($tokens).")") {
throw new UnexpectedTokenException($tokens);
}
$concat[] = $term2;
}
}
$exp[] = "(" . implode(".", $concat) . ")";

View File

@ -1047,6 +1047,13 @@ class TemplateTest extends TestCase
array('{"string" ~ "one" ~ "end"}', "stringoneend"),
array('{"string" ~ 1 ~ "end"}', "string1end"),
array('{$one ~= "string"} is {$one}', "1string is 1string"),
array('{"string" ~~ $one ~~ up("end")}', "string 1 END"),
array('{"string" ~~ $one++ ~~ "end"}', "string 1 end"),
array('{"string" ~~ ++$one ~~ "end"}', "string 2 end"),
array('{"string" ~~ "one" ~~ "end"}', "string one end"),
array('{"string" ~~ 1 ~~ "end"}', "string 1 end"),
array('{$one ~= "string"} is {$one}', "1string is 1string"),
);
}