Created
July 9, 2013 17:31
-
-
Save phillip-haydon/5959381 to your computer and use it in GitHub Desktop.
Sample view for BuildStarted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Sandra.Snow.PreCompiler.PostData> | |
@using System.Collections.Generic | |
@{ | |
Layout = "default.cshtml"; | |
} | |
<h1>Archives</h1> | |
@foreach(var year in Model.PostsGroupedByYearThenMonth) | |
{ | |
@foreach(var month in year.Value) | |
{ | |
<h2>@month.Key, @year.Key</h2> | |
<ul class="archive fancy-container darkishred"> | |
@foreach(var post in month.Value) | |
{ | |
<li><a href="@post.Url">@post.Title</a></li> | |
} | |
</ul> | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = new Dictionary<int, Dictionary<int, List<Post>>> | |
{ | |
{ | |
2013, new Dictionary<int, List<Post>> | |
{ | |
{ | |
12, new List<Post> | |
{ | |
new Post | |
{ | |
Title = "Hello World 2013 - 12", | |
Url = "My Url" | |
} | |
} | |
}, | |
{ | |
3, new List<Post> | |
{ | |
new Post | |
{ | |
Title = "Hello World 2013 - 03", | |
Url = "My Url" | |
} | |
} | |
}, | |
} | |
}, | |
{ | |
2012, new Dictionary<int, List<Post>> | |
{ | |
{ | |
11, new List<Post> | |
{ | |
new Post | |
{ | |
Title = "Hello World 2012 - 11", | |
Url = "My Url" | |
}, | |
new Post | |
{ | |
Title = "Hello World 2012 - 11 another one same month", | |
Url = "My Url" | |
} | |
} | |
}, | |
{ | |
4, new List<Post> | |
{ | |
new Post | |
{ | |
Title = "Hello World 2012 - 03", | |
Url = "My Url" | |
} | |
} | |
}, | |
} | |
}, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Post | |
{ | |
public Title { get; set; } | |
public Url { get; set; } | |
} |
If you can't figure it out, don't worry, I actually updated the keys to be DateTime for another section. So its not an issue now :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so this is how it should work but i don't currently have a way to get the outer loop so everything there should work except the @parent.Key - i'll figure something out eventually