Giving the TextField display template some markup around the value.

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-07-25 23:38:14 -07:00
parent f1ee35535f
commit b1a761b640
5 changed files with 25 additions and 21 deletions

View File

@@ -1,2 +1,3 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.Core.Common.Fields.TextField>" %>
<%: Model.Value %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Common.Fields.TextField>" %>
<%@ Import Namespace="Orchard.Utility.Extensions" %>
<p class="text-field"><span class="name"><%:Model.Name.CamelFriendly() %>:</span> <%:Model.Value %></p>

View File

@@ -1,22 +1,5 @@
using System.Linq;
using System.Text.RegularExpressions;
namespace Orchard.ContentTypes.Extensions {
namespace Orchard.ContentTypes.Extensions {
public static class StrinExtensions {
private static readonly Regex humps = new Regex("[A-Z][^A-Z]*");
public static string CamelFriendly(this string camel) {
if (camel == null)
return null;
var matches = humps.Matches(camel).OfType<Match>().Select(m => m.Value);
if (matches.Any()) {
return matches.Aggregate((a, b) => a + " " + b).TrimStart(' ');
}
else {
return camel;
}
}
public static string TrimEnd(this string rough, string trim = "") {
if (rough == null)
return null;

View File

@@ -5,6 +5,7 @@ using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels;
using Orchard.ContentTypes.Extensions;
using Orchard.Mvc.ViewModels;
using Orchard.Utility.Extensions;
namespace Orchard.ContentTypes.ViewModels {
public class EditTypeViewModel : BaseViewModel {

View File

@@ -800,6 +800,13 @@ table .button {
}
/* Fields
----------------------------------------------------------*/
/* TextField */
#main .summary .text-field {
margin:.5em 0;
}
/* ---------- Generic ---------- */
#main .breadcrumb {
margin-top:-1.5em;

View File

@@ -1,8 +1,20 @@
using System.Text.RegularExpressions;
using System.Linq;
using System.Text.RegularExpressions;
using Orchard.Localization;
namespace Orchard.Utility.Extensions {
public static class StringExtensions {
private static readonly Regex humps = new Regex("[A-Z][^A-Z]*");
public static string CamelFriendly(this string camel) {
if (camel == null)
return null;
var matches = humps.Matches(camel).OfType<Match>().Select(m => m.Value);
return matches.Any()
? matches.Aggregate((a, b) => a + " " + b).TrimStart(' ')
: camel;
}
public static string Ellipsize(this string text, int characterCount) {
return text.Ellipsize(characterCount, "&#160;&#8230;");
}