Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System.Web;
using Sitecore.StaticAssets.Infrastructure;
namespace Sitecore.StaticAssets.Html.Helpers
{
public static class StaticAssets
{
private static StaticAssetResolver _assetResolver;
public static void Initialize(StaticAssetResolver staticAssetResolver)
{
if (_assetResolver == null)
_assetResolver = staticAssetResolver;
}
public static HtmlString RenderScript(string path)
{
var actualPath = _assetResolver.GetActualPath(path);
return new HtmlString($"<script src=\"{ actualPath }\"></script>");
}
public static HtmlString RenderStyle(string path)
{
var actualPath = _assetResolver.GetActualPath(path);
return new HtmlString($"<link href=\"{ actualPath }\" rel=\"stylesheet\" />");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment