mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix #144: invalid ternary operator priority
This commit is contained in:
parent
a09b2f7620
commit
f985fff314
@ -667,6 +667,10 @@ class Template extends Render
|
|||||||
$var = false;
|
$var = false;
|
||||||
}
|
}
|
||||||
if ($tokens->is('?', '!')) {
|
if ($tokens->is('?', '!')) {
|
||||||
|
if($cond) {
|
||||||
|
$term = array_pop($exp) . ' ' . $term;
|
||||||
|
$term = '('. array_pop($exp) . ' ' . $term . ')';
|
||||||
|
}
|
||||||
$term = $this->parseTernary($tokens, $term, $var);
|
$term = $this->parseTernary($tokens, $term, $var);
|
||||||
$var = false;
|
$var = false;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@ class TemplateTest extends TestCase
|
|||||||
array('hello, {"World"}!', $a, 'hello, World!'),
|
array('hello, {"World"}!', $a, 'hello, World!'),
|
||||||
array('hello, {"W{$a}d"}!', $a, 'hello, WWorldd!'),
|
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, world!'),
|
||||||
|
array('hello, {!$world->chunk(1)->self->chunk("new")}!', $b, 'hello, !'),
|
||||||
array(':: {Fenom\Helper::method()->page->title} ::', $b, ':: test page ::'),
|
array(':: {Fenom\Helper::method()->page->title} ::', $b, ':: test page ::'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -657,6 +658,7 @@ class TemplateTest extends TestCase
|
|||||||
array('{0 ? "no way" : "right"}', $a),
|
array('{0 ? "no way" : "right"}', $a),
|
||||||
array('{$a ? "right" : "no way"}', $a),
|
array('{$a ? "right" : "no way"}', $a),
|
||||||
array('{1 ? "right" : "no way"}', $a),
|
array('{1 ? "right" : "no way"}', $a),
|
||||||
|
array('{$a == 1 ? "right" : "no way"}', $a),
|
||||||
// !
|
// !
|
||||||
array('{if $a!} right {/if}', $a),
|
array('{if $a!} right {/if}', $a),
|
||||||
array('{if 1!} right {/if}', $a),
|
array('{if 1!} right {/if}', $a),
|
||||||
|
Loading…
Reference in New Issue
Block a user