Skip to content

Instantly share code, notes, and snippets.

@soen
Last active June 25, 2020 00:26
Show Gist options
  • Save soen/fb6c254d3be109c58044d7659abbea7a to your computer and use it in GitHub Desktop.
Save soen/fb6c254d3be109c58044d7659abbea7a to your computer and use it in GitHub Desktop.
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