kreta/KretaWeb/Helpers/IconExtensions.cs
2024-03-13 00:33:46 +01:00

27 lines
813 B
C#

using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class IconExtensions
{
public static MvcHtmlString KretaIcon(this HtmlHelper helper, string icon, IDictionary<string, object> htmlAttributes = null)
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format("<i class=\"fa {0}\" ", icon));
if (htmlAttributes != null)
{
foreach (var item in htmlAttributes)
{
sb.Append(string.Format(" {0}=\"{1}\" ", item.Key, item.Value.ToString()));
}
}
sb.Append("></i>");
MvcHtmlString str = new MvcHtmlString(sb.ToString());
return str;
}
}
}