I find doing this sort of thing quite ugly and somewhat "primitive":
if ($something) echo ' class="current"';
if ($something) $c = ' class="current"';
It might be more verbose, but it's more readable and it's logical. Even if you're using templates, there must come a point where you have to go through the ugliness above (or something similar to it), so I wonder how MVC advocates deal with this. Do you use PHP's DOM extension? If not, then what do you do?
var p = document.createElement('p');
if (something) p.className = 'insect';