예제 #1
0
        private void AttachDynamicScripts(HttpContextBase httpContext)
        {
            var paths = DynamicScriptExtensions.GetRegisteredPaths(httpContext).ToArray();

            if (paths.Any())
            {
                const string headerName = "X-Scripts";

                var    bundle = DynamicBundleCreator.GerOrCreateScriptBundleFor(paths);
                string urls   = Scripts.RenderFormat("{0}", bundle.Path)
                                .ToHtmlString()
                                .Trim()
                                .Replace(Environment.NewLine, ",");
                httpContext.Response.Headers.Add(headerName, urls);
            }
        }
예제 #2
0
        public static IHtmlString RenderDynamicScripts(this HtmlHelper helper)
        {
            if (helper == null)
            {
                throw new ArgumentNullException(nameof(helper));
            }

            var registeredPaths = GetRegisteredPaths(helper.ViewContext.HttpContext);

            if (!registeredPaths.Any())
            {
                return(MvcHtmlString.Empty);
            }

            var bundle = DynamicBundleCreator.GerOrCreateScriptBundleFor(registeredPaths);

            return(Scripts.Render(bundle.Path));
        }