mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Updated UnorderedList to return IHtmlString and changed the relevant <%= blocks to <%:
--HG-- branch : dev
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Web.Mvc;
|
|||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.Mvc.Html;
|
using Orchard.Mvc.Html;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Orchard.Tests.Mvc.Html {
|
namespace Orchard.Tests.Mvc.Html {
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
@@ -133,6 +134,32 @@ namespace Orchard.Tests.Mvc.Html {
|
|||||||
Assert.AreEqual(@"<option value=""value""><br /></option>", result.ToString());
|
Assert.AreEqual(@"<option value=""value""><br /></option>", result.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void UnorderedListWithNullItemsReturnsEmptyHtmlString() {
|
||||||
|
//arrange
|
||||||
|
var viewContext = new ViewContext();
|
||||||
|
var viewDataContainer = new Mock<IViewDataContainer>();
|
||||||
|
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
|
||||||
|
|
||||||
|
//act
|
||||||
|
var result = html.UnorderedList((IEnumerable<string>)null, (a, b) => "", "test");
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.AreEqual(string.Empty, result.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void UnorderedListWithEmptyItemsReturnsEmptyHtmlString() {
|
||||||
|
//arrange
|
||||||
|
var viewContext = new ViewContext();
|
||||||
|
var viewDataContainer = new Mock<IViewDataContainer>();
|
||||||
|
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
|
||||||
|
|
||||||
|
//act
|
||||||
|
var result = html.UnorderedList(new string[]{}, (a, b) => "", "test");
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.AreEqual(string.Empty, result.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Core.Contents.ViewModels.DisplayItemViewModel>" %>
|
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Core.Contents.ViewModels.DisplayItemViewModel>" %>
|
||||||
|
|
||||||
<div class="preview">
|
<div class="preview">
|
||||||
<%=Html.DisplayForItem(m=>m.Content) %>
|
<%: Html.DisplayForItem(m=>m.Content) %>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Core.Contents.ViewModels.DisplayItemViewModel>" %>
|
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Core.Contents.ViewModels.DisplayItemViewModel>" %>
|
||||||
|
|
||||||
<%=Html.DisplayForItem(m=>m.Content) %>
|
<%: Html.DisplayForItem(m=>m.Content) %>
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Core.Routable.ViewModels.RoutableDisplayViewModel>" %>
|
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Core.Routable.ViewModels.RoutableDisplayViewModel>" %>
|
||||||
<% Html.AddTitleParts(Model.Routable.Item.Title); %>
|
<% Html.AddTitleParts(Model.Routable.Item.Title); %>
|
||||||
<%=Html.DisplayForItem(m=>m.Routable) %>
|
<%: Html.DisplayForItem(m=>m.Routable) %>
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
Html.RegisterStyle("admin.css"); %>
|
Html.RegisterStyle("admin.css"); %>
|
||||||
<h1><%:Html.TitleForPage(T("Manage Settings").ToString()) %></h1>
|
<h1><%:Html.TitleForPage(T("Manage Settings").ToString()) %></h1>
|
||||||
<h2><%:T("Cultures this site supports") %></h2>
|
<h2><%:T("Cultures this site supports") %></h2>
|
||||||
<%=Html.UnorderedList(
|
<%: Html.UnorderedList(
|
||||||
Model.SiteCultures.OrderBy(s => s),
|
Model.SiteCultures.OrderBy(s => s),
|
||||||
(s, i) => Html.DisplayFor(scvm => s, s == Model.CurrentCulture ? "CurrentCulture" : "RemovableCulture", "").ToString(),
|
(s, i) => Html.DisplayFor(scvm => s, s == Model.CurrentCulture ? "CurrentCulture" : "RemovableCulture", "").ToString(),
|
||||||
"site-cultures", "culture", "odd")%>
|
"site-cultures", "culture", "odd")%>
|
||||||
|
@@ -23,13 +23,13 @@
|
|||||||
<li class="previous">
|
<li class="previous">
|
||||||
<h4><%=year %> <span>(<%=yearMonths.Sum(ym => ym.Value) %>)</span></h4><%
|
<h4><%=year %> <span>(<%=yearMonths.Sum(ym => ym.Value) %>)</span></h4><%
|
||||||
} %>
|
} %>
|
||||||
<%=Html.UnorderedList(yearMonths, (t, i) => Html.Link(string.Format("{0:MMMM} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %>
|
<%: Html.UnorderedList(yearMonths, (t, i) => Html.Link(string.Format("{0:MMMM} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %>
|
||||||
</li><%
|
</li><%
|
||||||
} %>
|
} %>
|
||||||
</ul><%
|
</ul><%
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<%=Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %><%
|
<%: Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %><%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogViewModel>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||||
<%=Html.DisplayForItem(m => m.Blog) %>
|
<%: Html.DisplayForItem(m => m.Blog) %>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogsViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogsViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||||
<%if (Model.Blogs.Count() > 0) { %>
|
<%if (Model.Blogs.Count() > 0) { %>
|
||||||
<%=Html.UnorderedList(Model.Blogs, (b, i) => Html.DisplayForItem(b).ToHtmlString(), "blogs contentItems") %><%
|
<%: Html.UnorderedList(Model.Blogs, (b, i) => Html.DisplayForItem(b).ToHtmlString(), "blogs contentItems") %><%
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<p><%: T("No blogs found.") %></p><%
|
<p><%: T("No blogs found.") %></p><%
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogForAdminViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogForAdminViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||||
<% Html.AddTitleParts(T("Manage Blog").ToString()); %>
|
<% Html.AddTitleParts(T("Manage Blog").ToString()); %>
|
||||||
<%=Html.DisplayForItem(m => m.Blog) %>
|
<%: Html.DisplayForItem(m => m.Blog) %>
|
@@ -5,7 +5,7 @@
|
|||||||
<%-- todo: Add helper text here when ready. <p><%: T("Possible text about setting up and managing a blog goes here.") %></p> --%><%
|
<%-- todo: Add helper text here when ready. <p><%: T("Possible text about setting up and managing a blog goes here.") %></p> --%><%
|
||||||
if (Model.Entries.Count() > 0) { %>
|
if (Model.Entries.Count() > 0) { %>
|
||||||
<div class="actions"><a class="add button primaryAction" href="<%=Url.BlogCreate() %>"><%: T("New Blog") %></a></div>
|
<div class="actions"><a class="add button primaryAction" href="<%=Url.BlogCreate() %>"><%: T("New Blog") %></a></div>
|
||||||
<%=Html.UnorderedList(Model.Entries, (entry, i) => {
|
<%: Html.UnorderedList(Model.Entries, (entry, i) => {
|
||||||
// Add blog post count rendering into "meta" zone
|
// Add blog post count rendering into "meta" zone
|
||||||
entry.ContentItemViewModel.Zones.AddAction("meta", html => {
|
entry.ContentItemViewModel.Zones.AddAction("meta", html => {
|
||||||
int draftCount = entry.TotalPostCount - entry.ContentItemViewModel.Item.PostCount;
|
int draftCount = entry.TotalPostCount - entry.ContentItemViewModel.Item.PostCount;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogPostViewModel>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogPostViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||||
<% Html.AddTitleParts(Model.Blog.Name); %>
|
<% Html.AddTitleParts(Model.Blog.Name); %>
|
||||||
<%=Html.DisplayForItem(m => m.BlogPost) %>
|
<%: Html.DisplayForItem(m => m.BlogPost) %>
|
||||||
|
@@ -11,4 +11,4 @@
|
|||||||
%>
|
%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%=Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%>
|
<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<ContentItemViewModel<BlogPost>>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<ContentItemViewModel<BlogPost>>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<%=Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
||||||
<% if (Model.Count() < 1) { %><div class="info message"><%: T("There are no posts for this blog.") %></div><% } %>
|
<% if (Model.Count() < 1) { %><div class="info message"><%: T("There are no posts for this blog.") %></div><% } %>
|
||||||
|
@@ -79,7 +79,7 @@
|
|||||||
Zone:<%: display.ZoneName ?? "(null)" %>
|
Zone:<%: display.ZoneName ?? "(null)" %>
|
||||||
Position:<%: display.Position ?? "(null)" %>
|
Position:<%: display.Position ?? "(null)" %>
|
||||||
<div style="margin-left: 20px; border: solid 1px black;">
|
<div style="margin-left: 20px; border: solid 1px black;">
|
||||||
<%=Html.DisplayFor(x => display.Model, display.TemplateName, display.Prefix)%>
|
<%: Html.DisplayFor(x => display.Model, display.TemplateName, display.Prefix)%>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<%
|
<%
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
if (feature.Descriptor.Dependencies != null) { %>
|
if (feature.Descriptor.Dependencies != null) { %>
|
||||||
<div class="dependencies">
|
<div class="dependencies">
|
||||||
<h4><%: T("Depends on:")%></h4>
|
<h4><%: T("Depends on:")%></h4>
|
||||||
<%=Html.UnorderedList(
|
<%: Html.UnorderedList(
|
||||||
feature.Descriptor.Dependencies.OrderBy(s => s),
|
feature.Descriptor.Dependencies.OrderBy(s => s),
|
||||||
(s, i) => Html.Link(s, string.Format("#{0}", s.AsFeatureId(n => T(n)))),
|
(s, i) => Html.Link(s, string.Format("#{0}", s.AsFeatureId(n => T(n)))),
|
||||||
"",
|
"",
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
<div class="related"><%
|
<div class="related"><%
|
||||||
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
|
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
|
||||||
var t = tenant; %>
|
var t = tenant; %>
|
||||||
<%=Html.DisplayFor(m => t, string.Format("ActionsFor{0}", tenant.State.CurrentState), "") %><%: T(" | ")%><%
|
<%: Html.DisplayFor(m => t, string.Format("ActionsFor{0}", tenant.State.CurrentState), "") %><%: T(" | ")%><%
|
||||||
} %>
|
} %>
|
||||||
<%: Html.ActionLink(T("Edit").ToString(), "Edit", new {name = tenant.Name, area = "Orchard.MultiTenancy"}) %><%
|
<%: Html.ActionLink(T("Edit").ToString(), "Edit", new {name = tenant.Name, area = "Orchard.MultiTenancy"}) %><%
|
||||||
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
|
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PageViewModel>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PageViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||||
<%@ Import Namespace="Orchard.Pages.ViewModels"%>
|
<%@ Import Namespace="Orchard.Pages.ViewModels"%>
|
||||||
<%=Html.DisplayForItem(m=>m.Page) %>
|
<%: Html.DisplayForItem(m=>m.Page) %>
|
||||||
|
@@ -2,4 +2,4 @@
|
|||||||
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
|
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
|
||||||
<h1><%: Html.TitleForPage(T("Sandbox Pages").ToString()) %></h1>
|
<h1><%: Html.TitleForPage(T("Sandbox Pages").ToString()) %></h1>
|
||||||
<p><%: Html.ActionLink(T("Add new page").ToString(), "create") %></p>
|
<p><%: Html.ActionLink(T("Add new page").ToString(), "create") %></p>
|
||||||
<%=Html.UnorderedList(Model.Pages, (sp, i) => Html.DisplayForItem(sp).ToHtmlString(), "pages contentItems") %>
|
<%: Html.UnorderedList(Model.Pages, (sp, i) => Html.DisplayForItem(sp).ToHtmlString(), "pages contentItems") %>
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<PageShowViewModel>" %>
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<PageShowViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
|
<%@ Import Namespace="Orchard.Sandbox.ViewModels" %>
|
||||||
<%=Html.DisplayForItem(Model.Page) %>
|
<%: Html.DisplayForItem(Model.Page) %>
|
||||||
|
@@ -12,6 +12,6 @@ if (!string.IsNullOrWhiteSpace(Model.Query)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Model.PageOfResults != null && Model.PageOfResults.Count() > 0) { %>
|
if (Model.PageOfResults != null && Model.PageOfResults.Count() > 0) { %>
|
||||||
<%=Html.UnorderedList(Model.PageOfResults, (r, i) => Html.DisplayForItem(r.Content).ToHtmlString() , "search-results contentItems") %>
|
<%: Html.UnorderedList(Model.PageOfResults, (r, i) => Html.DisplayForItem(r.Content).ToHtmlString() , "search-results contentItems") %>
|
||||||
<%=Html.Pager(Model.PageOfResults, Model.PageOfResults.PageNumber, Model.DefaultPageSize, new {q = Model.Query}) %><%
|
<%=Html.Pager(Model.PageOfResults, Model.PageOfResults.PageNumber, Model.DefaultPageSize, new {q = Model.Query}) %><%
|
||||||
} %>
|
} %>
|
@@ -1,7 +1,7 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TagsIndexViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TagsIndexViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Tags.ViewModels"%>
|
<%@ Import Namespace="Orchard.Tags.ViewModels"%>
|
||||||
<h1 class="page-title"><%: Html.TitleForPage(T("Tags").ToString())%></h1>
|
<h1 class="page-title"><%: Html.TitleForPage(T("Tags").ToString())%></h1>
|
||||||
<%=Html.UnorderedList(
|
<%: Html.UnorderedList(
|
||||||
Model.Tags,
|
Model.Tags,
|
||||||
(t, i) => Html.ActionLink(
|
(t, i) => Html.ActionLink(
|
||||||
Html.Encode(t.TagName),
|
Html.Encode(t.TagName),
|
||||||
|
@@ -2,4 +2,4 @@
|
|||||||
<%@ Import Namespace="Orchard.Tags.ViewModels"%>
|
<%@ Import Namespace="Orchard.Tags.ViewModels"%>
|
||||||
<% Html.AddTitleParts(T("Tags").ToString(), T("Contents tagged with {0}", Model.TagName).ToString()); %>
|
<% Html.AddTitleParts(T("Tags").ToString(), T("Contents tagged with {0}", Model.TagName).ToString()); %>
|
||||||
<h1 class="page-title"><%=T("Contents tagged with <span>{0}</span>", Html.Encode(Model.TagName)) %></h1>
|
<h1 class="page-title"><%=T("Contents tagged with <span>{0}</span>", Html.Encode(Model.TagName)) %></h1>
|
||||||
<%=Html.UnorderedList(Model.Items, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "taggedPosts contentItems") %>
|
<%: Html.UnorderedList(Model.Items, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "taggedPosts contentItems") %>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<ContentItemViewModel<BlogPost>>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<ContentItemViewModel<BlogPost>>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<%=Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
||||||
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<ContentItemViewModel<BlogPost>>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<ContentItemViewModel<BlogPost>>>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<%=Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
||||||
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
||||||
|
@@ -11,4 +11,4 @@
|
|||||||
%>
|
%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%=Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%>
|
<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%>
|
||||||
|
@@ -2,5 +2,5 @@
|
|||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
|
|
||||||
<%=Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
||||||
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
||||||
|
@@ -11,4 +11,4 @@
|
|||||||
%>
|
%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%=Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%>
|
<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%>
|
||||||
|
@@ -2,5 +2,5 @@
|
|||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
|
|
||||||
<%=Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
||||||
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
<% if (Model.Count() < 1) { %><p><%: T("There are no posts for this blog.") %></p><% } %>
|
||||||
|
@@ -23,13 +23,13 @@
|
|||||||
<li class="previous">
|
<li class="previous">
|
||||||
<h4><%=year %> <span>(<%=yearMonths.Sum(ym => ym.Value) %>)</span></h4><%
|
<h4><%=year %> <span>(<%=yearMonths.Sum(ym => ym.Value) %>)</span></h4><%
|
||||||
} %>
|
} %>
|
||||||
<%=Html.UnorderedList(yearMonths, (t, i) => Html.Link(string.Format("{0:MMMM} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %>
|
<%: Html.UnorderedList(yearMonths, (t, i) => Html.Link(string.Format("{0:MMMM} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %>
|
||||||
</li><%
|
</li><%
|
||||||
} %>
|
} %>
|
||||||
</ul><%
|
</ul><%
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<%=Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %><%
|
<%: Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %><%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
|
@@ -112,16 +112,16 @@ namespace Orchard.Mvc.Html {
|
|||||||
|
|
||||||
#region UnorderedList
|
#region UnorderedList
|
||||||
|
|
||||||
public static string UnorderedList<T>(this HtmlHelper htmlHelper, IEnumerable<T> items, Func<T, int, string> generateContent, string cssClass) {
|
public static IHtmlString UnorderedList<T>(this HtmlHelper htmlHelper, IEnumerable<T> items, Func<T, int, string> generateContent, string cssClass) {
|
||||||
return htmlHelper.UnorderedList(items, generateContent, cssClass, null, null);
|
return htmlHelper.UnorderedList(items, generateContent, cssClass, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string UnorderedList<T>(this HtmlHelper htmlHelper, IEnumerable<T> items, Func<T, int, string> generateContent, string cssClass, string itemCssClass, string alternatingItemCssClass) {
|
public static IHtmlString UnorderedList<T>(this HtmlHelper htmlHelper, IEnumerable<T> items, Func<T, int, string> generateContent, string cssClass, string itemCssClass, string alternatingItemCssClass) {
|
||||||
return UnorderedList(items, generateContent, cssClass, t => itemCssClass, t => alternatingItemCssClass);
|
return UnorderedList(items, generateContent, cssClass, t => itemCssClass, t => alternatingItemCssClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string UnorderedList<T>(IEnumerable<T> items, Func<T, int, string> generateContent, string cssClass, Func<T, string> generateItemCssClass, Func<T, string> generateAlternatingItemCssClass) {
|
private static IHtmlString UnorderedList<T>(IEnumerable<T> items, Func<T, int, string> generateContent, string cssClass, Func<T, string> generateItemCssClass, Func<T, string> generateAlternatingItemCssClass) {
|
||||||
if (items == null || items.Count() == 0) return "";
|
if (items == null || !items.Any()) return new HtmlString(string.Empty);
|
||||||
|
|
||||||
var sb = new StringBuilder(250);
|
var sb = new StringBuilder(250);
|
||||||
int counter = 0, count = items.Count() - 1;
|
int counter = 0, count = items.Count() - 1;
|
||||||
@@ -155,7 +155,7 @@ namespace Orchard.Mvc.Html {
|
|||||||
|
|
||||||
sb.Append("</ul>");
|
sb.Append("</ul>");
|
||||||
|
|
||||||
return sb.ToString();
|
return new HtmlString(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Reference in New Issue
Block a user