public static ConvertAttributes ( |
||
attributes | A list of attributes to convert | |
return | string |
/// <summary> /// Render HTML for a link /// </summary> /// <param name="link">The link to render</param> /// <param name="attributes">Addtiional parameters to add. Do not include href or title</param> /// <param name="contents">Content to go in the link instead of the standard text</param> /// <returns>An "a" HTML element</returns> public static RenderingResult BeginRenderLink(Fields.Link link, SafeDictionary <string> attributes, string contents, TextWriter writer) { if (link == null) { return(new RenderingResult(writer, string.Empty, string.Empty)); } if (attributes == null) { attributes = new SafeDictionary <string>(); } string format = "<a href='{0}' {1}>{2}"; contents = contents == null ? link.Text ?? link.Title : contents; AttributeCheck(attributes, "class", link.Class); AttributeCheck(attributes, "target", link.Target); AttributeCheck(attributes, "title", link.Title); string firstPart = format.Formatted(link.BuildUrl(attributes), Utilities.ConvertAttributes(attributes), contents); string lastPart = "</a>"; return(new RenderingResult(writer, firstPart, lastPart)); }
/// <summary> /// Render HTML for a link /// </summary> /// <param name="link">The link to render</param> /// <param name="attributes">Addtiional parameters to add. Do not include href or title</param> /// <param name="contents">Content to go in the link instead of the standard text</param> /// <returns>An "a" HTML element</returns> public static RenderingResult BeginRenderLink(Link link, SafeDictionary <string> attributes, string contents, TextWriter writer) { if (link == null) { return(new RenderingResult(writer, string.Empty, string.Empty)); } if (attributes == null) { attributes = new SafeDictionary <string>(); } contents = contents == null ? link.Text ?? link.Title : contents; var url = link.BuildUrl(attributes); url = HttpUtility.HtmlEncode(url); //we decode and then encode the HTML to avoid a double encoding of HTML characters. //some versions of Sitecore save '&' as '&' and others as '&'. contents = HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(contents)); var title = HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(link.Title)); AttributeCheck(attributes, "class", link.Class); AttributeCheck(attributes, "target", link.Target); AttributeCheck(attributes, "title", title); string firstPart = LinkTagFormat.Formatted(url, Utilities.ConvertAttributes(attributes, QuotationMark), contents, QuotationMark); string lastPart = "</a>"; return(new RenderingResult(writer, firstPart, lastPart)); }
/// <summary> /// Render HTML for a link /// </summary> /// <param name="link">The link to render</param> /// <param name="attributes">Addtiional attributes to add. Do not include href or title</param> /// <param name="contents">Content to go in the link instead of the standard text</param> /// <returns>An "a" HTML element</returns> public virtual string RenderLink(Fields.Link link, NameValueCollection attributes, string contents) { if (link == null) { return(""); } if (attributes == null) { attributes = new NameValueCollection(); } string format = "<a href='{0}{1}' title='{2}' target='{3}' class='{4}' {5}>{6}</a>"; string cls = attributes.AllKeys.Any(x => x == "class") ? attributes["class"] : link.Class; string anchor = link.Anchor.IsNullOrEmpty() ? "" : "#" + link.Anchor; string target = attributes.AllKeys.Any(x => x == "target") ? attributes["target"] : link.Target; AttributeCheck(attributes, "class", link.Class); AttributeCheck(attributes, "target", link.Target); AttributeCheck(attributes, "title", link.Title); attributes.Remove("href"); return(format.Formatted(link.Url, anchor, link.Title, target, cls, Utilities.ConvertAttributes(attributes), contents.IsNullOrEmpty() ? link.Text : contents)); }
/// <summary> /// Render HTML for a link /// </summary> /// <param name="link">The link to render</param> /// <param name="attributes">Addtiional parameters to add. Do not include href or title</param> /// <param name="contents">Content to go in the link instead of the standard text</param> /// <returns>An "a" HTML element</returns> public static RenderingResult BeginRenderLink(Link link, SafeDictionary <string> attributes, string contents, TextWriter writer) { if (link == null) { return(new RenderingResult(writer, string.Empty, string.Empty)); } if (attributes == null) { attributes = new SafeDictionary <string>(); } contents = contents == null ? link.Text ?? link.Title : contents; AttributeCheck(attributes, "class", link.Class); AttributeCheck(attributes, "target", link.Target); AttributeCheck(attributes, "title", link.Title); var url = link.BuildUrl(attributes); url = HttpUtility.HtmlEncode(url); string firstPart = LinkTagFormat.Formatted(url, Utilities.ConvertAttributes(attributes, QuotationMark), contents, QuotationMark); string lastPart = "</a>"; return(new RenderingResult(writer, firstPart, lastPart)); }
/// <summary> /// Renders HTML for an image /// </summary> /// <param name="image">The image to render</param> /// <param name="attributes">Additional attributes to add. Do not include alt or src</param> /// <returns>An img HTML element</returns> public virtual string RenderImage(Fields.Image image, NameValueCollection attributes) { if (image == null) { return(""); } if (attributes == null) { attributes = new NameValueCollection(); } string format = "<img src='{0}' {1}/>"; //should there be some warning about these removals? AttributeCheck(attributes, "class", image.Class); AttributeCheck(attributes, "alt", image.Alt); if (image.Height > 0) { AttributeCheck(attributes, "height", image.Height.ToString()); } if (image.Width > 0) { AttributeCheck(attributes, "width", image.Width.ToString()); } return(format.Formatted(image.Src, Utilities.ConvertAttributes(attributes))); }
public virtual string RenderImage(Fields.Image image, NameValueCollection attributes) { /* * ME - This method is used to render images rather than going back to the fieldrender * because it stops another call having to be passed to Sitecore. */ if (image == null || image.Src.IsNullOrWhiteSpace()) { return(""); } if (attributes == null) { attributes = new NameValueCollection(); } var builder = new UrlBuilder(image.Src); //append to url values if (attributes[ImageWidth].IsNotNullOrEmpty()) { attributes.Add(ImageParameters.WIDTH, attributes[ImageWidth]); } else { attributes.Add(ImageParameters.WIDTH, image.Width.ToString()); } if (attributes[ImageHeight].IsNotNullOrEmpty()) { attributes.Add(ImageParameters.HEIGHT, attributes[ImageHeight]); } else { attributes.Add(ImageParameters.HEIGHT, image.Height.ToString()); } foreach (var key in attributes.AllKeys) { if (key == "alt" || key == "class" || key == "style") { continue; } builder[key] = attributes[key]; } //should there be some warning about these removals? AttributeCheck(attributes, "class", image.Class); AttributeCheck(attributes, "alt", image.Alt); return(ImageTagFormat.Formatted(builder.ToString(), Utilities.ConvertAttributes(attributes))); }
/// <summary> /// Render HTML for a link /// </summary> /// <param name="link">The link to render</param> /// <param name="attributes">Addtiional parameters to add. Do not include href or title</param> /// <param name="contents">Content to go in the link instead of the standard text</param> /// <returns>An "a" HTML element</returns> public static RenderingResult BeginRenderLink(Link link, SafeDictionary <string> attributes, string contents, TextWriter writer, bool alwaysRender, string aElementTemplate) { if (link == null) { if (alwaysRender) { link = new Link(); } else { return(new RenderingResult(writer, string.Empty, string.Empty)); } } if (attributes == null) { attributes = new SafeDictionary <string>(); } contents = contents == null ? link.Text ?? link.Title : contents; var url = link.BuildUrl(attributes); url = HttpUtility.HtmlEncode(url); //we decode and then encode the HTML to avoid a double encoding of HTML characters. //some versions of Sitecore save '&' as '&' and others as '&'. contents = HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(contents)); var title = HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(link.Title)); AttributeCheck(attributes, "class", link.Class); AttributeCheck(attributes, "target", link.Target); AttributeCheck(attributes, "title", title); AttributeCheck(attributes, "style", link.Style); #if SC90 || SC91 if (attributes["target"] == "_blank" && Settings.ProtectExternalLinksWithBlankTarget) { AttributeCheck(attributes, "rel", "noopener noreferrer"); } #endif string firstPart = aElementTemplate.Formatted(url, Utilities.ConvertAttributes(attributes, QuotationMark), contents, QuotationMark); string lastPart = "</a>"; return(new RenderingResult(writer, firstPart, lastPart)); }
public virtual string RenderImage(Fields.Image image, NameValueCollection attributes) { var urlParams = new NameValueCollection(); var htmlParams = new NameValueCollection(); /* * ME - This method is used to render images rather than going back to the fieldrender * because it stops another call having to be passed to Sitecore. */ if (image == null || image.Src.IsNullOrWhiteSpace()) { return(""); } if (attributes == null) { attributes = new NameValueCollection(); } Action <string> remove = key => attributes.Remove(key); Action <string> url = key => { urlParams.Add(key, attributes[key]); remove(key); }; Action <string> html = key => { htmlParams.Add(key, attributes[key]); remove(key); }; Action <string> both = key => { htmlParams.Add(key, attributes[key]); urlParams.Add(key, attributes[key]); remove(key); }; foreach (var key in attributes.AllKeys) { switch (key) { case ImageParameters.BORDER: case ImageParameters.ALT: case ImageParameters.HSPACE: case ImageParameters.VSPACE: case ImageParameters.CLASS: html(key); break; case ImageParameters.OUTPUT_METHOD: case ImageParameters.ALLOW_STRETCH: case ImageParameters.IGNORE_ASPECT_RATIO: case ImageParameters.SCALE: case ImageParameters.MAX_WIDTH: case ImageParameters.MAX_HEIGHT: case ImageParameters.THUMBNAIL: case ImageParameters.BACKGROUND_COLOR: case ImageParameters.DATABASE: case ImageParameters.LANGUAGE: case ImageParameters.VERSION: case ImageParameters.DISABLE_MEDIA_CACHE: url(key); break; case ImageParameters.WIDTH: case ImageParameters.HEIGHT: both(key); break; default: both(key); break; } } var builder = new UrlBuilder(image.Src); foreach (var key in urlParams.AllKeys) { builder[key] = urlParams[key]; } //should there be some warning about these removals? AttributeCheck(htmlParams, ImageParameters.CLASS, image.Class); AttributeCheck(htmlParams, ImageParameters.ALT, image.Alt); AttributeCheck(htmlParams, ImageParameters.BORDER, image.Border); if (image.HSpace > 0) { AttributeCheck(htmlParams, ImageParameters.HSPACE, image.HSpace.ToString(CultureInfo.InvariantCulture)); } if (image.VSpace > 0) { AttributeCheck(htmlParams, ImageParameters.VSPACE, image.VSpace.ToString(CultureInfo.InvariantCulture)); } if (htmlParams.AllKeys.Any(x => x == ImageParameters.HEIGHT)) { htmlParams["height"] = htmlParams[ImageParameters.HEIGHT]; htmlParams.Remove(ImageParameters.HEIGHT); } if (htmlParams.AllKeys.Any(x => x == ImageParameters.WIDTH)) { htmlParams["width"] = htmlParams[ImageParameters.WIDTH]; htmlParams.Remove(ImageParameters.WIDTH); } return(ImageTagFormat.Formatted(builder.ToString(), Utilities.ConvertAttributes(htmlParams))); }
/// <summary> /// Render HTML for a link /// </summary> /// <param name="link">The link to render</param> /// <param name="attributes">Addtiional attributes to add. Do not include href or title</param> /// <param name="contents">Content to go in the link instead of the standard text</param> /// <returns>An "a" HTML element</returns> public static RenderingResult BeginRenderLink(Fields.Link link, NameValueCollection attributes, string contents, TextWriter writer) { if (link == null) { return(new RenderingResult(writer, string.Empty, string.Empty)); } if (attributes == null) { attributes = new NameValueCollection(); } string format = "<a href='{0}{1}' {2}>{3}"; contents = contents == null ? link.Text ?? link.Title : contents; Func <string, Func <string>, string> getValue = (key, func) => { var value = attributes.AllKeys.Any(x => x == key) ? attributes[key] : func(); attributes.Remove(key); return(value); }; UrlBuilder builder = new UrlBuilder(link.Url); var query = getValue("query", () => link.Query); var anchor = getValue("anchor", () => link.Anchor); if (query.IsNotNullOrEmpty()) { builder.AddQueryString(query); } AttributeCheck(attributes, "class", link.Class); AttributeCheck(attributes, "target", link.Target); AttributeCheck(attributes, "title", link.Title); string firstPart = format.Formatted(builder.ToString(), anchor.IsNullOrEmpty() ? "" : "#" + anchor, Utilities.ConvertAttributes(attributes), contents); string lastPart = "</a>"; return(new RenderingResult(writer, firstPart, lastPart)); }
/// <summary> /// Renders HTML for an image /// </summary> /// <param name="image">The image to render</param> /// <param name="attributes">Additional parameters to add. Do not include alt or src</param> /// <param name="outputHeightWidth">Indicates if the height and width attributes should be output when rendering the image</param> /// <returns>An img HTML element</returns> public virtual string RenderImage( Image image, SafeDictionary <string> attributes, bool outputHeightWidth = false ) { if (image == null) { return(string.Empty); } if (attributes == null) { attributes = new SafeDictionary <string>(); } var origionalKeys = attributes.Keys.ToList(); //should there be some warning about these removals? AttributeCheck(attributes, ImageParameterKeys.CLASS, image.Class); if (!attributes.ContainsKey(ImageParameterKeys.ALT)) { attributes[ImageParameterKeys.ALT] = image.Alt; } AttributeCheck(attributes, ImageParameterKeys.BORDER, image.Border); if (image.HSpace > 0) { AttributeCheck(attributes, ImageParameterKeys.HSPACE, image.HSpace.ToString(CultureInfo.InvariantCulture)); } if (image.VSpace > 0) { AttributeCheck(attributes, ImageParameterKeys.VSPACE, image.VSpace.ToString(CultureInfo.InvariantCulture)); } if (image.Width > 0) { AttributeCheck(attributes, ImageParameterKeys.WIDTHHTML, image.Width.ToString(CultureInfo.InvariantCulture)); } if (image.Height > 0) { AttributeCheck(attributes, ImageParameterKeys.HEIGHTHTML, image.Height.ToString(CultureInfo.InvariantCulture)); } var urlParams = new SafeDictionary <string>(); var htmlParams = new SafeDictionary <string>(); /* * ME - This method is used to render images rather than going back to the fieldrender * because it stops another call having to be passed to Sitecore. */ if (image == null || image.Src.IsNullOrWhiteSpace()) { return(String.Empty); } if (attributes == null) { attributes = new SafeDictionary <string>(); } Action <string> remove = key => attributes.Remove(key); Action <string> url = key => { urlParams.Add(key, attributes[key]); remove(key); }; Action <string> html = key => { htmlParams.Add(key, attributes[key]); remove(key); }; Action <string> both = key => { htmlParams.Add(key, attributes[key]); urlParams.Add(key, attributes[key]); remove(key); }; var keys = attributes.Keys.ToList(); foreach (var key in keys) { //if we have not config we just add it to both if (SitecoreContext.Config == null) { both(key); } else { bool found = false; if (SitecoreContext.Config.ImageAttributes.Contains(key)) { html(key); found = true; } if (SitecoreContext.Config.ImageQueryString.Contains(key)) { url(key); found = true; } if (!found) { html(key); } } } //copy width and height across to url if (!urlParams.ContainsKey(ImageParameterKeys.WIDTH) && !urlParams.ContainsKey(ImageParameterKeys.HEIGHT)) { if (origionalKeys.Contains(ImageParameterKeys.WIDTHHTML)) { urlParams[ImageParameterKeys.WIDTH] = htmlParams[ImageParameterKeys.WIDTHHTML]; } if (origionalKeys.Contains(ImageParameterKeys.HEIGHTHTML)) { urlParams[ImageParameterKeys.HEIGHT] = htmlParams[ImageParameterKeys.HEIGHTHTML]; } } if (!urlParams.ContainsKey(ImageParameterKeys.LANGUAGE) && image.Language != null) { urlParams[ImageParameterKeys.LANGUAGE] = image.Language.Name; } //calculate size var finalSize = Utilities.ResizeImage( image.Width, image.Height, urlParams[ImageParameterKeys.SCALE].ToFlaot(), urlParams[ImageParameterKeys.WIDTH].ToInt(), urlParams[ImageParameterKeys.HEIGHT].ToInt(), urlParams[ImageParameterKeys.MAX_WIDTH].ToInt(), urlParams[ImageParameterKeys.MAX_HEIGHT].ToInt()); if (finalSize.Height > 0) { urlParams[ImageParameterKeys.HEIGHT] = finalSize.Height.ToString(); } if (finalSize.Width > 0) { urlParams[ImageParameterKeys.WIDTH] = finalSize.Width.ToString(); } Action <string, string> originalAttributeClean = (exists, missing) => { if (origionalKeys.Contains(exists) && !origionalKeys.Contains(missing)) { urlParams.Remove(missing); htmlParams.Remove(missing); } }; //we do some smart clean up originalAttributeClean(ImageParameterKeys.WIDTHHTML, ImageParameterKeys.HEIGHTHTML); originalAttributeClean(ImageParameterKeys.HEIGHTHTML, ImageParameterKeys.WIDTHHTML); if (!outputHeightWidth) { htmlParams.Remove(ImageParameterKeys.WIDTHHTML); htmlParams.Remove(ImageParameterKeys.HEIGHTHTML); } var builder = new UrlBuilder(image.Src); foreach (var key in urlParams.Keys) { builder.AddToQueryString(key, urlParams[key]); } string mediaUrl = builder.ToString(); #if (SC81 || SC80 || SC75 || SC82) mediaUrl = ProtectMediaUrl(mediaUrl); #endif mediaUrl = HttpUtility.HtmlEncode(mediaUrl); return(ImageTagFormat.Formatted(mediaUrl, Utilities.ConvertAttributes(htmlParams, QuotationMark), QuotationMark)); }
/// <summary> /// Renders HTML for an image /// </summary> /// <param name="image">The image to render</param> /// <param name="attributes">Additional parameters to add. Do not include alt or src</param> /// <param name="outputHeightWidth">Indicates if the height and width attributes should be output when rendering the image</param> /// <returns>An img HTML element</returns> public virtual string RenderImage( Fields.Image image, SafeDictionary <string> attributes, bool outputHeightWidth = false ) { if (image == null) { return(string.Empty); } if (attributes == null) { attributes = new SafeDictionary <string>(); } var origionalKeys = attributes.Keys.ToList(); //should there be some warning about these removals? AttributeCheck(attributes, ImageParameterKeys.CLASS, image.Class); AttributeCheck(attributes, ImageParameterKeys.ALT, image.Alt); AttributeCheck(attributes, ImageParameterKeys.BORDER, image.Border); if (image.HSpace > 0) { AttributeCheck(attributes, ImageParameterKeys.HSPACE, image.HSpace.ToString(CultureInfo.InvariantCulture)); } if (image.VSpace > 0) { AttributeCheck(attributes, ImageParameterKeys.VSPACE, image.VSpace.ToString(CultureInfo.InvariantCulture)); } if (image.Width > 0) { AttributeCheck(attributes, ImageParameterKeys.WIDTHHTML, image.Width.ToString(CultureInfo.InvariantCulture)); } if (image.Height > 0) { AttributeCheck(attributes, ImageParameterKeys.HEIGHTHTML, image.Height.ToString(CultureInfo.InvariantCulture)); } var urlParams = new SafeDictionary <string>(); var htmlParams = new SafeDictionary <string>(); /* * ME - This method is used to render images rather than going back to the fieldrender * because it stops another call having to be passed to Sitecore. */ if (image == null || image.Src.IsNullOrWhiteSpace()) { return(""); } if (attributes == null) { attributes = new SafeDictionary <string>(); } Action <string> remove = key => attributes.Remove(key); Action <string> url = key => { urlParams.Add(key, attributes[key]); remove(key); }; Action <string> html = key => { htmlParams.Add(key, attributes[key]); remove(key); }; Action <string> both = key => { htmlParams.Add(key, attributes[key]); urlParams.Add(key, attributes[key]); remove(key); }; var keys = attributes.Keys.ToList(); foreach (var key in keys) { switch (key) { case ImageParameterKeys.BORDER: case ImageParameterKeys.ALT: case ImageParameterKeys.HSPACE: case ImageParameterKeys.VSPACE: case ImageParameterKeys.CLASS: case ImageParameterKeys.WIDTHHTML: case ImageParameterKeys.HEIGHTHTML: html(key); break; case ImageParameterKeys.OUTPUT_METHOD: case ImageParameterKeys.ALLOW_STRETCH: case ImageParameterKeys.IGNORE_ASPECT_RATIO: case ImageParameterKeys.SCALE: case ImageParameterKeys.MAX_WIDTH: case ImageParameterKeys.MAX_HEIGHT: case ImageParameterKeys.THUMBNAIL: case ImageParameterKeys.BACKGROUND_COLOR: case ImageParameterKeys.DATABASE: case ImageParameterKeys.LANGUAGE: case ImageParameterKeys.VERSION: case ImageParameterKeys.DISABLE_MEDIA_CACHE: case ImageParameterKeys.WIDTH: case ImageParameterKeys.HEIGHT: url(key); break; default: html(key); break; } } //copy width and height across to url if (!urlParams.ContainsKey(ImageParameterKeys.WIDTH) && !urlParams.ContainsKey(ImageParameterKeys.HEIGHT)) { if (origionalKeys.Contains(ImageParameterKeys.WIDTHHTML)) { urlParams[ImageParameterKeys.WIDTH] = htmlParams[ImageParameterKeys.WIDTHHTML]; } if (origionalKeys.Contains(ImageParameterKeys.HEIGHTHTML)) { urlParams[ImageParameterKeys.HEIGHT] = htmlParams[ImageParameterKeys.HEIGHTHTML]; } } if (!urlParams.ContainsKey(ImageParameterKeys.LANGUAGE) && image.Language != null) { urlParams[ImageParameterKeys.LANGUAGE] = image.Language.Name; } //calculate size var finalSize = Utilities.ResizeImage( image.Width, image.Height, urlParams[ImageParameterKeys.SCALE].ToFlaot(), urlParams[ImageParameterKeys.WIDTH].ToInt(), urlParams[ImageParameterKeys.HEIGHT].ToInt(), urlParams[ImageParameterKeys.MAX_WIDTH].ToInt(), urlParams[ImageParameterKeys.MAX_HEIGHT].ToInt()); urlParams[ImageParameterKeys.HEIGHT] = finalSize.Height.ToString(); urlParams[ImageParameterKeys.WIDTH] = finalSize.Width.ToString(); Action <string, string> originalAttributeClean = (exists, missing) => { if (origionalKeys.Contains(exists) && !origionalKeys.Contains(missing)) { urlParams.Remove(missing); htmlParams.Remove(missing); } }; //we do some smart clean up originalAttributeClean(ImageParameterKeys.WIDTHHTML, ImageParameterKeys.HEIGHTHTML); originalAttributeClean(ImageParameterKeys.HEIGHTHTML, ImageParameterKeys.WIDTHHTML); if (!outputHeightWidth) { htmlParams.Remove(ImageParameterKeys.WIDTHHTML); htmlParams.Remove(ImageParameterKeys.HEIGHTHTML); } var builder = new UrlBuilder(image.Src); foreach (var key in urlParams.Keys) { builder.AddToQueryString(key, urlParams[key]); } string mediaUrl = builder.ToString(); #if (SC80 || SC75) mediaUrl = ProtectMediaUrl(mediaUrl); #endif return(ImageTagFormat.Formatted(mediaUrl, Utilities.ConvertAttributes(htmlParams, QuotationMark), QuotationMark)); }
/// <summary> /// Render HTML for a link /// </summary> /// <param name="link">The link to render</param> /// <param name="attributes">Addtiional attributes to add. Do not include href or title</param> /// <param name="contents">Content to go in the link instead of the standard text</param> /// <returns>An "a" HTML element</returns> public static RenderingResult BeginRenderLink(Fields.Link link, NameValueCollection attributes, string contents, TextWriter writer) { if (link == null) { return(new RenderingResult(writer, string.Empty, string.Empty)); } if (attributes == null) { attributes = new NameValueCollection(); } string format = "<a href='{0}{1}' title='{2}' model='{3}' class='{4}' {5}>{6}"; string cls = attributes.AllKeys.Any(x => x == "class") ? attributes["class"] : link.Class; string anchor = link.Anchor.IsNullOrEmpty() ? "" : "#" + link.Anchor; string target = attributes.AllKeys.Any(x => x == "model") ? attributes["model"] : link.Target; contents = contents == null ? link.Text ?? link.Title : contents; AttributeCheck(attributes, "class", link.Class); AttributeCheck(attributes, "model", link.Target); AttributeCheck(attributes, "title", link.Title); attributes.Remove("href"); string firstPart = format.Formatted(link.Url, anchor, link.Title, target, cls, Utilities.ConvertAttributes(attributes), contents); string lastPart = "</a>"; return(new RenderingResult(writer, firstPart, lastPart)); }