This article describes a very nice feature of ASP.NET MVC3 Razor View Engine: Templates.

@helper tabs(params Tab[] tabs) {
<ul>
  @foreach(var tab in tabs) {
  <li><a href="@tab.Url" >@tab.Text</a></li>
  }
</ul>
}

Read the full article here.