MVC has conditional attributes built in. For example:
<div @{if (myClass != null) { <text>class="@myClass"</text> } }>Content</div>
<div class="@myClass">Content</div>
If @myClass is null, it just won’t use the attribute at all.
I know that may not quite solve your current issue, but it is noteworthy!
See also: John Galloway’s blog post on ASP.NET MVC 4 Beta > Conditional attribute rendering