diff --git a/src/DeloitteDigital.Atlas/Mvc/HtmlExtensions.cs b/src/DeloitteDigital.Atlas/Mvc/HtmlExtensions.cs
index f65933d..b82a146 100644
--- a/src/DeloitteDigital.Atlas/Mvc/HtmlExtensions.cs
+++ b/src/DeloitteDigital.Atlas/Mvc/HtmlExtensions.cs
@@ -18,11 +18,13 @@ public static MvcEditFrame BeginEditFrame(this HtmlHelper helper, string d
return frame;
}
- public static IDisposable BeginLink(this HtmlHelper htmlHelper, ILinkFieldRenderingString linkField, string alternateTag = null, bool skipInPageEditor = false)
+ public static IDisposable BeginLink(this HtmlHelper htmlHelper, ILinkFieldRenderingString linkField, string alternateTag = null, bool skipInPageEditor = false, bool alternateTagInPageEditor = false, string linkTagClass = null)
{
if (skipInPageEditor && global::Sitecore.Context.PageMode.IsExperienceEditor)
return new EmptyMvcLink();
- return new MvcLink(htmlHelper.ViewContext, linkField, alternateTag);
+ if (alternateTagInPageEditor && global::Sitecore.Context.PageMode.IsExperienceEditor)
+ return new MvcLink(htmlHelper.ViewContext, null, alternateTag, linkTagClass);
+ return new MvcLink(htmlHelper.ViewContext, linkField, alternateTag, linkTagClass);
}
}
}
diff --git a/src/DeloitteDigital.Atlas/Mvc/MvcLink.cs b/src/DeloitteDigital.Atlas/Mvc/MvcLink.cs
index 290d2d5..be7062c 100644
--- a/src/DeloitteDigital.Atlas/Mvc/MvcLink.cs
+++ b/src/DeloitteDigital.Atlas/Mvc/MvcLink.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Web.Mvc;
using DeloitteDigital.Atlas.FieldRendering;
@@ -16,11 +17,11 @@ internal class MvcLink : IDisposable
private readonly ViewContext viewContext;
private readonly TagBuilder tagBuilder;
- public MvcLink(ViewContext viewContext, ILinkFieldRenderingString linkField, string alternateTag)
+ public MvcLink(ViewContext viewContext, ILinkFieldRenderingString linkField, string alternateTag, string linkTagClass = null)
{
this.viewContext = viewContext;
- if (linkField?.Url != null)
+ if (!string.IsNullOrWhiteSpace(linkField?.Url))
{
// link given - render an anchor tag
this.tagBuilder = new TagBuilder("a");
@@ -28,12 +29,24 @@ public MvcLink(ViewContext viewContext, ILinkFieldRenderingString linkField, str
// add optional attributes
if (!string.IsNullOrWhiteSpace(linkField.Target))
this.tagBuilder.Attributes.Add("target", linkField.Target);
- if (!string.IsNullOrWhiteSpace(linkField.Class))
- this.tagBuilder.Attributes.Add("class", linkField.Class);
if (!string.IsNullOrWhiteSpace(linkField.Description))
this.tagBuilder.Attributes.Add("title", linkField.Description);
+
+ if (!string.IsNullOrWhiteSpace(linkField.Class) && !string.IsNullOrWhiteSpace(linkTagClass))
+ {
+ var classes = new HashSet();
+ foreach (var linkClass in linkField.Class.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
+ classes.Add(linkClass);
+ foreach (var tagClass in linkTagClass.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
+ classes.Add(tagClass);
+ this.tagBuilder.Attributes.Add("class", string.Join(" ", classes));
+ }
+ else if (!string.IsNullOrWhiteSpace(linkField.Class))
+ this.tagBuilder.Attributes.Add("class", linkField.Class);
+ else if (!string.IsNullOrWhiteSpace(linkTagClass))
+ this.tagBuilder.Attributes.Add("class", linkTagClass);
}
- else if (string.IsNullOrWhiteSpace(alternateTag))
+ else if (!string.IsNullOrWhiteSpace(alternateTag))
{
// no link given - render the alternate tag if provided
this.tagBuilder = new TagBuilder(alternateTag);
diff --git a/src/DeloitteDigital.Atlas/Properties/AssemblyInfo.cs b/src/DeloitteDigital.Atlas/Properties/AssemblyInfo.cs
index 6251488..f7731aa 100644
--- a/src/DeloitteDigital.Atlas/Properties/AssemblyInfo.cs
+++ b/src/DeloitteDigital.Atlas/Properties/AssemblyInfo.cs
@@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Deloitte Digital")]
[assembly: AssemblyProduct("DeloitteDigital.Atlas")]
-[assembly: AssemblyCopyright("Copyright © Deloitte Digital 2016")]
+[assembly: AssemblyCopyright("Copyright © Deloitte Digital 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("2.1.0.0")]
+[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
\ No newline at end of file