From 806467453d0124cc44c6ded095be56b3513aa0ce Mon Sep 17 00:00:00 2001 From: bzick Date: Sat, 23 May 2015 23:09:16 +0300 Subject: [PATCH] Done #165 --- sandbox/fenom.php | 2 +- src/Fenom/Template.php | 6 ++++-- tests/cases/Fenom/TemplateTest.php | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sandbox/fenom.php b/sandbox/fenom.php index 5c954d9..c525228 100644 --- a/sandbox/fenom.php +++ b/sandbox/fenom.php @@ -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"); \ No newline at end of file diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php index d547891..bc47b4b 100644 --- a/src/Fenom/Template.php +++ b/src/Fenom/Template.php @@ -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) . ")"; diff --git a/tests/cases/Fenom/TemplateTest.php b/tests/cases/Fenom/TemplateTest.php index d663587..21e897c 100644 --- a/tests/cases/Fenom/TemplateTest.php +++ b/tests/cases/Fenom/TemplateTest.php @@ -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"), ); }