Conditional operator in Mako using Pylons
- by Antoine Leclair
In PHP, I often use the conditional operator to add an attribute to an html element if it applies to the element in question. For example:
<select name="blah">
<option value="1"<?= $blah == 1 ? ' selected="selected"' : '' ?>>
One
</option>
<option value="2"<?= $blah == 2 ? ' selected="selected"' :…