title: Embed HTML output within razor function-call?
body: <p>I'm looking at <a href="http://bugsquash.blogspot.co.il/2009/02/repeater-with-separator-for-aspnet-mvc.html" rel="nofollow">this</a> page, which contains the following razor extension:</p>
  
  <pre><code>public static void Repeat&lt;T&gt;(this HtmlHelper html, IEnumerable&lt;T&gt; items, Action&lt;T&gt; render, Action separator)
  </code></pre>
  
  <p>Here is the usage example from that page:</p>
  
  <pre><code>&lt;% Html.Repeat(Model.Products, p =&gt; { %&gt; 
      &lt;div&gt;&lt;%= p.Id%&gt;&lt;/div&gt;
      &lt;div&gt;&lt;%= p.Name%&gt;&lt;/div&gt;
  &lt;%}, () =&gt; { %&gt; 
      &lt;br /&gt; &lt;%-- separator --%&gt;
  &lt;% }); %&gt;
  </code></pre>
  
  <p>I can't figure out how to translate the above snippet to razor code, how do I embed Html output in a function-call code-block?</p>
  
  <p>I tried this:</p>
  
  <pre><code>@Html.Repeat(
    items: Model.Nodes,
    render: node =&gt; @: &lt;a href='@node.Title'&gt;@node.Url&lt;a /&gt;
  , separator: () =&gt; @:|
  )
  </code></pre>
  
  <p>But I get the following exception:</p>
  
  <blockquote>
    <p>CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement</p>
  </blockquote>
  
  <p>I updated the <code>Repeat</code> function as answered bellow, now my razor code looks like the following:</p>
  
  <pre><code>@{
    Html.Repeat(
      items: Model.Nodes,
      template: @&lt;text&gt;&lt;a href="@item.Url"&gt;@item.Title&lt;/a&gt;&lt;/text&gt;,
      separator:  @&lt;text&gt; | &lt;/text&gt;);
  }
  </code></pre>
  
  <p>But in fact no item is being rendered.</p>