We have a ton of spark views I'm migrating over to Razor and in many places we use the inline spark if syntax as shown below.
<viewdata about="AboutViewModel" />
<div class="button-container" if="about.shouldShowButton">
<button class="about-acknowledge" type="button">Click Me</button>
</div>
I'm looking for a nice compact similar razor syntax. But all I've been able to come up with is this.
@if(ViewData["about.shouldShowButton"].Equals(true)){
<div class="button-container">
<button class="about-acknowledge" type="button">Click Me</button>
</div>
}
While individually that's not terrible, when you have a few of them close together and they are nested in other tags it gets pretty nasty real fast.
EDIT
I've made my view into a strongly typed view and that has cleaned it up a little but I would still like something a little more compact if possible.
@model Project.Models.AboutViewModel
@if(Model.ShouldShowButton){
<div class="button-container">
<button class="about-acknowledge" type="button">Click Me</button>
</div>
}