protected override void RenderContents(HtmlTextWriter output)
        {
            var link = GetLink(false);

            if (ClientSettings.BundlingEnabled)
            {
                var bundle = BundleHelper.GetJsBundle(link);
                if (bundle == null)
                {
                    bundle          = BundleHelper.JsBundle(link).Include(link, true);
                    bundle.UseCache = false;
                    BundleHelper.AddBundle(bundle);
                }
                output.Write(BundleHelper.HtmlScript(link));
            }
            else
            {
                output.Write(BundleHelper.HtmlScript(VirtualPathUtility.ToAbsolute(link), false, false));
            }
        }
        protected override void RenderContents(HtmlTextWriter output)
        {
            var link = GetLink();

            output.Write(BundleHelper.GetJavascriptLink(VirtualPathUtility.ToAbsolute(link), false));
        }
        private string BundleHtml(string category, string html)
        {
            var result = new StringBuilder();

            var hash    = HttpServerUtility.UrlTokenEncode(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(html)));
            var path    = string.Format("~{0}{1}-{2}", BundleHelper.BUNDLE_VPATH, GetCategory(category), hash);
            var pathcss = path + ".css";
            var pathjs  = path + ".js";

            var bundlecss = BundleHelper.GetCssBundle(pathcss);
            var bundlejs  = BundleHelper.GetJsBundle(pathjs);

            if (bundlecss == null && bundlejs == null)
            {
                var document = new HtmlDocument();
                document.LoadHtml(html);

                if (bundlecss == null)
                {
                    var styles = document.DocumentNode.SelectNodes("/style | /link[@rel='stylesheet'] | /link[@rel='stylesheet/less']");
                    if (styles != null && 0 < styles.Count)
                    {
                        bundlecss = BundleHelper.CssBundle(pathcss);
                        foreach (var style in styles)
                        {
                            if (style.Name == "style" && !string.IsNullOrEmpty(style.InnerHtml))
                            {
                                throw new NotSupportedException("Embedded styles not supported.");
                            }
                            bundlecss.Include(style.Attributes["href"].Value);
                        }
                        BundleHelper.AddBundle(bundlecss);
                    }
                }

                if (bundlejs == null)
                {
                    var scripts = document.DocumentNode.SelectNodes("/script");
                    if (scripts != null && 0 < scripts.Count)
                    {
                        bundlejs = BundleHelper.JsBundle(pathjs);
                        foreach (var script in scripts)
                        {
                            if (script.Attributes["src"] == null && !string.IsNullOrEmpty(script.InnerHtml))
                            {
                                throw new NotSupportedException("Embedded scripts not supported.");
                            }
                            bundlejs.Include(script.Attributes["src"].Value, script.Attributes["notobfuscate"] == null);
                        }
                        BundleHelper.AddBundle(bundlejs);
                    }
                }
            }

            if (bundlecss != null)
            {
                result.AppendLine(BundleHelper.HtmlLink(pathcss));
            }
            if (bundlejs != null)
            {
                result.AppendLine(BundleHelper.HtmlScript(pathjs));
            }
            return(result.ToString());
        }