|
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 |
terryjohnson Smarty Rookie
Joined: 03 Jan 2004 Posts: 9 Location: Chatham, ON, Canada
|
Posted: Mon Mar 15, 2004 9:16 pm Post subject: Short Form of IF - {$var ? 'foo' : 'bar'} |
|
|
If it is not already possible to do this (as an undocumented feature), please could it be added?
It would be very useful for translating boolean values into human-readable texts. For example:
Customer is {$bloke ? 'Male' : 'Female'} |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Mar 15, 2004 9:20 pm Post subject: |
|
|
You can do this with if/else pretty easily:
{if $bloke}Male{else}Female{/if}
If you want, you can make a modifier:
{$bloke|bool:"Male":"Female"} |
|
Back to top |
|
kloshar4o Smarty n00b
Joined: 23 Feb 2019 Posts: 1
|
Posted: Sat Feb 23, 2019 7:30 pm Post subject: |
|
|
I dont know why is it so hard to find this on the internet, but here it is :
{($bloke) ? 'Male' : 'Female'} |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Feb 24, 2019 12:08 pm Post subject: |
|
|
Perhaps, because it was asked 15 years ago? |
|
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
|