Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Ternary operator

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
idealists
Smarty n00b


Joined: 11 Dec 2008
Posts: 1

PostPosted: Thu Dec 11, 2008 2:01 pm    Post subject: Ternary operator Reply with quote

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
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Fri Dec 12, 2008 9:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP