mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
commit
5dc7bbfd56
@ -667,6 +667,10 @@ class Template extends Render
|
||||
$var = false;
|
||||
}
|
||||
if ($tokens->is('?', '!')) {
|
||||
if($cond) {
|
||||
$term = array_pop($exp) . ' ' . $term;
|
||||
$term = '('. array_pop($exp) . ' ' . $term . ')';
|
||||
}
|
||||
$term = $this->parseTernary($tokens, $term, $var);
|
||||
$var = false;
|
||||
}
|
||||
@ -780,7 +784,7 @@ class Template extends Render
|
||||
if ($this->_options & Fenom::DENY_METHODS) {
|
||||
throw new \LogicException("Forbidden to call methods");
|
||||
}
|
||||
return $this->parseChain($tokens, $code);
|
||||
return $unary . $this->parseChain($tokens, $code);
|
||||
} elseif ($tokens->is(Tokenizer::MACRO_INCDEC)) {
|
||||
if($this->_options & Fenom::FORCE_VERIFY) {
|
||||
return $unary . '(isset(' . $code . ') ? ' . $code . $tokens->getAndNext() . ' : null)';
|
||||
|
@ -83,7 +83,7 @@ class Tokenizer
|
||||
public static $macros = array(
|
||||
self::MACRO_STRING => array(
|
||||
\T_ABSTRACT => 1, \T_ARRAY => 1, \T_AS => 1, \T_BREAK => 1,
|
||||
\T_BREAK => 1, \T_CASE => 1, \T_CATCH => 1, \T_CLASS => 1,
|
||||
\T_CASE => 1, \T_CATCH => 1, \T_CLASS => 1,
|
||||
\T_CLASS_C => 1, \T_CLONE => 1, \T_CONST => 1, \T_CONTINUE => 1,
|
||||
\T_DECLARE => 1, \T_DEFAULT => 1, \T_DIR => 1, \T_DO => 1,
|
||||
\T_ECHO => 1, \T_ELSE => 1, \T_ELSEIF => 1, \T_EMPTY => 1,
|
||||
|
@ -106,6 +106,7 @@ class TemplateTest extends TestCase
|
||||
array('hello, {"World"}!', $a, 'hello, World!'),
|
||||
array('hello, {"W{$a}d"}!', $a, 'hello, WWorldd!'),
|
||||
array('hello, {$world->chunk(1)->self->chunk("new")}!', $b, 'hello, world!'),
|
||||
array('hello, {!$world->chunk(1)->self->chunk("new")}!', $b, 'hello, !'),
|
||||
array(':: {Fenom\Helper::method()->page->title} ::', $b, ':: test page ::'),
|
||||
);
|
||||
}
|
||||
@ -657,6 +658,8 @@ class TemplateTest extends TestCase
|
||||
array('{0 ? "no way" : "right"}', $a),
|
||||
array('{$a ? "right" : "no way"}', $a),
|
||||
array('{1 ? "right" : "no way"}', $a),
|
||||
array('{$a == 1 ? "right" : "no way"}', $a),
|
||||
array('{$a > 0 ? "right" : "no way"}', $a),
|
||||
// !
|
||||
array('{if $a!} right {/if}', $a),
|
||||
array('{if 1!} right {/if}', $a),
|
||||
|
Loading…
Reference in New Issue
Block a user