예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var parent = context.GetValue <AccordionTagHelper>("Accordion");

            AddHeader(output);
            output.TagName = "div";
            output.AddClass("collapse");
            output.Attributes.Add("id", TagHelper.Id);
            if (TagHelper.Active ?? false)
            {
                output.AddClass("show");
            }
            output.AddAttribute("aria-labelledby", $"head-{TagHelper.Id}");
            output.AddAttribute("data-parent", $"__PARENT_ID__");
            AddBody(output);
            output.Content.SetContent((await output.GetChildContentAsync()).GetContent());
            var writer = new System.IO.StringWriter();

            output.WriteTo(writer, NullHtmlEncoder.Default);
            var content = writer.ToString();

            output.SuppressOutput();
            context.GetValue <AccordionItemList>().Add(new AccordionItem {
                Order = TagHelper.Order, Content = content
            });
        }
    private void AddToContext(TagHelperContext context, TagHelperOutput output)
    {
        var getOutputAsHtml = output.Render(_encoder);

        var itemList = context.GetValue <List <CarouselItem> >(CarouselItemsContent);

        itemList.Add(new CarouselItem(getOutputAsHtml, TagHelper.Active ?? false));
    }
예제 #3
0
        public void GetValue()
        {
            var context = new TagHelperContext(
                new TagHelperAttributeList(),
                new Dictionary <object, object>(),
                Guid.NewGuid().ToString("N"));

            context.GetValue <string>().ShouldBe(default);
예제 #4
0
        public void Init()
        {
            var tagHelper        = new TestTagHelper(new TestTagHelperService());
            var tagHelperContext = new TagHelperContext(
                new TagHelperAttributeList(),
                new Dictionary <object, object>(),
                Guid.NewGuid().ToString("N"));

            Should.NotThrow(() => tagHelper.Init(tagHelperContext));
            tagHelperContext.GetValue <List <string> >().ShouldBeEmpty();
        }
예제 #5
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            SetPlaceholderForNameIfNotProvided();

            var tabHeader = GetTabHeaderItem(context, output);

            var tabHeaderItems = context.GetValue <List <TabItem> >(TabItems);

            tabHeaderItems.Add(new TabItem(tabHeader, "", false, TagHelper.Name, TagHelper.ParentDropdownName, false));

            output.SuppressOutput();
        }
예제 #6
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            SetRandomIdIfNotProvided();

            var innerContent = (await output.GetChildContentAsync().ConfigureAwait(false)).GetContent();

            var html = GetAccordionHeaderItem(context, output) + GetAccordionContentItem(context, output, innerContent);

            var tabHeaderItems = context.GetValue <List <string> >(AccordionItems);

            tabHeaderItems.Add(html);

            output.SuppressOutput();
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var list = context.GetValue <List <CarouselItem> >(CarouselTagHelper.CAROUSEL_ITEMS_CONTENT);

            list.Add(new CarouselItem {
                IsActive = IsActive ?? false
            });
            output.TagName = "div";
            output.AddClass("carousel-item");
            if (IsActive ?? false)
            {
                output.AddClass("active");
            }
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";
            output.TagMode = TagMode.StartTagAndEndTag;
            AddBasicAttributes(context, output);
            await output.GetChildContentAsync();

            var itemList = context.GetValue <List <CarouselItem> >(CAROUSEL_ITEMS_CONTENT);

            SetOneItemAsActive(context, output, itemList);
            SetIndicators(context, output, itemList);
            output.PreContent.AppendHtml("<div class=\"carousel-inner\">");
            output.PostContent.AppendHtml("</div>");
            SetControls(context, output, itemList);
        }
        protected virtual void AddGroupToFormGroupContents(TagHelperContext context, string propertyName, string html, int order, out bool suppress)
        {
            var list = context.GetValue <List <FormGroupItem> >(FormGroupContents) ?? new List <FormGroupItem>();

            suppress = list == null;

            if (list != null && !list.Any(igc => igc.HtmlContent.Contains("id=\"" + propertyName.Replace('.', '_') + "\"")))
            {
                list.Add(new FormGroupItem
                {
                    HtmlContent = html,
                    Order       = order
                });
            }
        }
        public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (string.IsNullOrWhiteSpace(TagHelper.Name))
            {
                throw new Exception("Name of tab dropdown tag can not bu null or empty.");
            }

            await output.GetChildContentAsync();

            var tabHeader = GetTabHeaderItem(context, output);

            var tabHeaderItems = context.GetValue <List <TabItem> >(TabItems);

            tabHeaderItems.Add(new TabItem(tabHeader, "", false, TagHelper.Name, "", true));

            output.SuppressOutput();
        }
예제 #11
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            SetPlaceholderForNameIfNotProvided();

            var innerContent = await output.GetChildContentAsync().ConfigureAwait(false);

            var tabHeader  = GetTabHeaderItem(context, output);
            var tabContent = GetTabContentItem(context, output, innerContent.GetContent());

            var tabHeaderItems = context.GetValue <List <TabItem> >(TabItems);

            var active = TagHelper.Active ?? false;

            tabHeaderItems.Add(new TabItem(tabHeader, tabContent, active, TagHelper.Name, TagHelper.ParentDropdownName, false));

            output.SuppressOutput();
        }
예제 #12
0
        private string ApplyContent(TagHelperContext context)
        {
            var children = context.GetValue <AccordionItemList>().OrderBy(i => i.Order).ToArray();

            for (var i = 0; i < children.Length; i++)
            {
                ref var item = ref children[i];
                item.Content = item.Content.Replace("__PARENT_ID__", $"#{TagHelper.Id}");
                if (i == children.Length - 1)
                {
                    item.Content = item.Content.Replace("__LAST_CARD_BODY__", "border-top").Replace("__LAST_CARD_HEADER__", "border-bottom-0");
                }
                else
                {
                    item.Content = item.Content.Replace("__LAST_CARD_BODY__", "border-bottom").Replace("__LAST_CARD_HEADER__", "");
                }
            }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "li";
            output.TagMode = TagMode.StartTagAndEndTag;
            output.Attributes.AddClass("breadcrumb-item");
            output.Attributes.AddClass(RocketBreadcrumbItemActivePlaceholder);

            var list = context.GetValue <List <BreadcrumbItem> >(BreadcrumbItemsContent);

            output.Content.SetHtmlContent(GetInnerHtml(context, output));

            list.Add(new BreadcrumbItem
            {
                Html   = output.Render(_encoder),
                Active = TagHelper.Active
            });

            output.SuppressOutput();
        }