Ternary operators #660
Closed
iamwizzdom
started this conversation in
Ideas
Replies: 5 comments 2 replies
|
bump - I want this too for templates. Example with "elvis" operator
could be simplified to
Thx |
0 replies
|
Can't this already be done with "default"?`{$myvar|default:"foobar"}`On Apr 30, 2023 7:05 AM, tpneumat ***@***.***> wrote:
bump - I want this too for templates. Example with "elvis" operator
{if $myvar}{$myvar}{else}N/A{/if}
could be simplified to
{$myvar?:'N/A'}
Thx
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
1 reply
|
Funny thing is that Smarty supports the ternary since 2009/2010. But it was never documented. Also, it requires the testing expression to be in parentheses. So this should work: {($foo) ? $var1 : $var2}But this will not: {$foo ? $var1 : $var2}There is no support for the shorthand |
1 reply
|
Ternary support is implemented in v5 |
0 replies
|
Thank you! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Please implement support for ternary operators such as $foo ?: null, $foo?->prop, $foo ? $var1 : $var2☺️
These ternary operators are very helpful in simplifying code. Thanks in advance
All reactions