util.py: add the toggleSelected() method

This commit is contained in:
Mike Bonnet 2008-09-19 13:34:53 -04:00
parent a50325b75d
commit bdc647872d

View file

@ -25,6 +25,17 @@ def toggleOrder(template, sortKey, orderVar='order'):
else:
return sortKey
def toggleSelected(template, var, option):
"""
If the passed in variable var equals the literal value in option,
return 'selected="selected"', otherwise return ''.
Used for setting the selected option in select boxes.
"""
if var == option:
return 'selected="selected"'
else:
return ''
def sortImage(template, sortKey, orderVar='order'):
"""
Return an html img tag suitable for inclusion in the sortKey of a sortable table,