|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
idealists Smarty n00b
Joined: 11 Dec 2008 Posts: 1
|
Posted: Thu Dec 11, 2008 2:01 pm Post subject: Ternary operator |
|
|
Does smarty have a ternary plugin, to add short/simple conditional statements, like:
(condition) ? value-if-true : value-if-false;
Dwoo has one, the underlying code of which looks fairly complicated (for me) to port to Smarty.
Thanks |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Fri Dec 12, 2008 9:09 am Post subject: |
|
|
I'm not aware of such a feature in Smarty.
If you really want it, you could either write a compiler plugin (I wouldn't know how to begin with that yet, though) or a prefilter that just replaces something like this
Code: | (condition) {?} value-if-true {:} value-if-false {;} |
with
Code: | {if (condition)} value-if-true {else} value-if-false {/if} |
The actual resulting Smarty syntax doesn't look that much more complicated though. _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|