public static IHtmlContent Script()

in src/PartsUnlimitedWebsite/ContentDeliveryNetworkExtensions.cs [44:69]


        public static IHtmlContent Script(this IHtmlHelper helper, string contentPath)
        {
            if (string.IsNullOrWhiteSpace(contentPath))
            {
                throw new ArgumentOutOfRangeException(nameof(contentPath), contentPath, "Must not be null or whitespace");
            }

            var sb = new StringBuilder();
            var paths = Configuration == null ? new[] { contentPath } : Configuration.Scripts[contentPath];

            foreach (var path in paths)
            {
                var script = new TagBuilder("script");

                script.MergeAttribute("type", "text/javascript");
                script.MergeAttribute("src", path);

                using (var writer = new StringWriter())
                {
                    script.WriteTo(writer, HtmlEncoder.Default);
                    sb.AppendLine(writer.ToString());
                }
            }

            return new HtmlString(sb.ToString());
        }