Пример #1
0
        /// <summary>
        /// Gets a html style tag for the specified asset.
        /// </summary>
        /// <param name="bundle">The name of the Webpack bundle.</param>
        /// <param name="fallbackBundle">The name of the bundle to fallback to if main bundle does not exist.</param>
        /// <returns>An HtmlString containing the html style tag.</returns>
        public async Task <HtmlString> GetStyleTagAsync(string bundle, string?fallbackBundle = null)
        {
            if (string.IsNullOrEmpty(bundle))
            {
                return(HtmlString.Empty);
            }

            bundle = TryFixCssBundleName(bundle);
            var file = await _manifestService.GetFromManifestAsync(bundle).ConfigureAwait(false);

            if (file == null)
            {
                if (string.IsNullOrEmpty(fallbackBundle))
                {
                    return(HtmlString.Empty);
                }

                fallbackBundle = TryFixCssBundleName(fallbackBundle);
                file           = await _manifestService.GetFromManifestAsync(fallbackBundle).ConfigureAwait(false);
            }

            return(file != null
                ? new HtmlString(await _tagBuilder.BuildStyleTagAsync(file).ConfigureAwait(false))
                : HtmlString.Empty);
        }