/// <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 }); }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (!output.Attributes.ContainsName("placeholder")) { output.AddAttribute("placeholder", $"请输入{TagHelper.Title}"); } var old = output.PreElement.GetContent(); output.PreElement.Clear(); switch (TagHelper.Orientation) { case Orientation.Horizontal: output.PreElement.AppendHtml($"<div class=\"form-group row\"><label class=\"col-md-2 col-form-label{TagHelper.Size switch { Size.Large => " col-form-label-lg",Size.Small=> " col-form-label-sm",_=>"" }}\" for=\"{output.Attributes["id"].Value}\">{TagHelper.Title}</label><div class=\"col-md-10\">{old}"); output.PostElement.AppendHtml($"</div></div>"); break;
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> public override void Process(TagHelperContext context, TagHelperOutput output) { switch (TagHelper.DropdownButtonType) { case DropdownButtonType.Single: output.AddClass("dropdown-toggle"); output.AddAttribute("data-toggle", "dropdown"); break; default: var tagbuilder = new TagBuilder(output.TagName); tagbuilder.MergeAttributes(output.Attributes.ToDictionary(a => a.Name, a => a.Value)); tagbuilder.AddClass("dropdown-toggle").AddClass("dropdown-toggle-split").AddAttribute("data-toggle", "dropdown"); output.PostElement.AppendHtml(tagbuilder); break; } }
public static void AddClass(this TagHelperOutput output, string valueToAdd) { output.AddAttribute(Constants.HtmlAttribute.CLASS, valueToAdd); }