如果我想多如果在HTML語句屬性我可能會做這樣的事情:多 - MVC剃刀
<input type="button" value="Bad, the title has a lot of excess spacing" title="@if(SomeModel.condOne) {
<text>this</text>
}
@if (SomeModel.CondTwo)
{
<text> is</text>
}
@if (SomeModel.CondThree)
{
<text> a title</text>
}
" />
但是,這創造了很多需要截斷空的空間。所以這個工程:
<input type="button" value="Good, the title is condenced" title="@if(SomeModel.condOne) {<text>this</text>}@if (SomeModel.CondTwo){<text> is</text>}@if (SomeModel.CondThree){<text> a title</text>}" />
同樣的原則也適用於多類元素(如類=「oddrow class1的」 - >類=「evenrow類class2」)
但是,這可能很難閱讀是否很長。並且,如果您觸摸括號或Ctrl-K,Ctrl-D(任何下一個開發人員可能會這樣做),Visual Studio都有將此語句分成多行的習慣。
是否有更好或更全面的方式來實現MVC剃刀一行中的多個屬性條件?