Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
Last active December 12, 2015 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsakamoto/4697249 to your computer and use it in GitHub Desktop.
Save jsakamoto/4697249 to your computer and use it in GitHub Desktop.
@{
var comics = new[] {
new {Title = "Groo", Publisher = "Dark Horse Comics"},
new {Title = "Spiderman", Publisher = "Marvel"}
};
}
<h1>Normal</h1>
<table border="1">
<tr><th>Title</th><th>Publisher</th></tr>
@Html.Repeater(
items: comics,
template:
@<tr>
<td>@item.Title</td>
<td>@item.Publisher</td>
</tr>
)
</table>
<h1>With Separator</h1>
<table border="1">
<tr><th>Title</th><th>Publisher</th></tr>
@Html.Repeater(
items: comics,
template:
@<tr>
<td>@item.Title</td>
<td>@item.Publisher</td>
</tr>,
separator: @<tr><td colspan="2">----</td></tr>
)
</table>
<h1>Empty</h1>
<table border="1">
<tr><th>Title</th><th>Publisher</th></tr>
@Html.Repeater(
items: comics.Where(_=> false),
template:
@<tr>
<td>@item.Title</td>
<td>@item.Publisher</td>
</tr>,
separator: @<tr><td colspan="2">----</td></tr>,
empty: @<tr><td colspan="2">nothing...</td></tr>
)
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment