Beispiel #1
0
        /// <summary>
        /// Call this method from the top level _Layout view, in the head section.
        /// It replaces the normal
        /// @Styles.Render("....") and
        /// @Scripts.Render("....")
        /// lines that sit near the top of the page.
        ///
        /// It renders all the bundles that the page needs (these can be different per page) and need to go
        /// near the top (mainly style bundles).
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// When this method is called, you have to add any bundles that need to be added,
        /// so the ones that need to be rendered at the top of the page can be rendered here.
        /// That is, when this runs, the time for gathering file dependencies is over and you need to
        /// process them into bundles.
        /// </remarks>
        public static IHtmlString DynamicBundlesTopRender()
        {
            if (!HttpContextStore.FirstTime())
            {
                return(new HtmlString(""));
            }

            List <AssetPath> assetDirectoryList = HttpContextStore.GetAssetDirectories();
            List <string>    scriptBundleVirtualPaths;
            List <string>    styleBundleVirtualPaths;

            _dynamicBundlesBuilder.Builder(assetDirectoryList, out scriptBundleVirtualPaths, out styleBundleVirtualPaths);

            HttpContextStore.StoreBottomBundleNames(scriptBundleVirtualPaths);

            // Note that Styles.Render assumes that all the bundles are StyleBundles
            return(Styles.Render(styleBundleVirtualPaths.ToArray()));
        }