Last active
June 25, 2020 00:26
-
-
Save soen/fb6c254d3be109c58044d7659abbea7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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