I have a a View with three news boxes: NewsOfTheDay, NewsOfTheWeek, NewsOfTheMonth. In my model I have this same three properties. Now my code looks like this:
@{var news=Model.NewsOfTheDay;}
<div class="newsbox">
<h2>@(news.Title)</h2>
<p>@(news.Text)</p>
<div>
<!--other html code-->
@{var news=Model.NewsOfTheWeek;}
<div class="newsbox">
<h2>@(news.Title)</h2>
<p>@(news.Text)</p>
<div>
So, as you see, I'm repeating html code here, there is more duplication, removed for clarity. Now, I could do some magic with partial views (Html.Action) but then I'll have to split my model.
Is there something equivalent to this: @RenderBox("NewsItem",Model.NewsOfTheWeek)