Пример #1
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var pbContext = new PhaseBannerContext();

            TagHelperContent childContent;

            using (context.SetScopedContextItem(typeof(PhaseBannerContext), pbContext))
            {
                childContent = await output.GetChildContentAsync();
            }

            if (!pbContext.Tag.HasValue)
            {
                throw new InvalidOperationException($"You must specify a <govuk-phase-banner-tag> child element.");
            }

            var tagBuilder = _htmlGenerator.GeneratePhaseBanner(
                pbContext.Tag.Value.content,
                pbContext.Tag.Value.attributes,
                childContent,
                output.Attributes.ToAttributesDictionary());

            output.TagName = tagBuilder.TagName;
            output.TagMode = TagMode.StartTagAndEndTag;

            output.Attributes.Clear();
            output.MergeAttributes(tagBuilder);
            output.Content.SetHtmlContent(tagBuilder.InnerHtml);
        }
Пример #2
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var phaseBannerContext = new PhaseBannerContext();

            IHtmlContent childContent;

            using (context.SetScopedContextItem(phaseBannerContext))
            {
                childContent = await output.GetChildContentAsync();
            }

            phaseBannerContext.ThrowIfIncomplete();

            var tagBuilder = _htmlGenerator.GeneratePhaseBanner(
                phaseBannerContext.Tag?.Content,
                phaseBannerContext.Tag?.Attributes,
                childContent,
                output.Attributes.ToAttributeDictionary());

            output.TagName = tagBuilder.TagName;
            output.TagMode = TagMode.StartTagAndEndTag;

            output.Attributes.Clear();
            output.MergeAttributes(tagBuilder);
            output.Content.SetHtmlContent(tagBuilder.InnerHtml);
        }