public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var template = @"<ul class=""list-group"">{0}</ul>"; var itemTemplate = @"<li class=""list-group-item"">{0}</li>"; var listContent = string.Empty; if (ListItems != null && ListItems.Any()) { var builder = new StringBuilder(); foreach (var item in ListItems) { builder.AppendLine(string.Format(itemTemplate, item)); } listContent = string.Format(template, builder); } else { var contentModel = context.SetItem <ListGroupTagHelper, MultipleItemsContext>(); contentModel.Items = new List <string>(); await output.GetChildContentAsync(); listContent = string.Join("", contentModel.Items); } output.TagName = ""; output.Content.AppendHtml(listContent); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var contentModel = context.SetItem <TabsTagHelper, MultipleItemsContext>(); await output.GetChildContentAsync(); var template = @"<ul class=""nav nav-tabs"" data-tabs=""tabs"" {2}> {0} </ul> <div class=""tab-content""> {1} </div>"; var idAttr = !string.IsNullOrEmpty(Id) ? string.Format(@"id=""{0}""", Id) : ""; var finalContent = string.Format(template, string.Join("", contentModel.Items.ToArray()), string.Join("", contentModel.Contents.ToArray()), idAttr); output.TagName = ""; output.Content.AppendHtml(finalContent); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var modalContext = context.SetItem <PanelTagHelper, BasicContext>(); await output.GetChildContentAsync(); var template = @"<div class=""panel {3}"" {4}> {0} {1} {2} </div>"; output.TagName = ""; var cssClass = !string.IsNullOrEmpty(CssClass) ? CssClass : "panel-default"; var idAttr = !string.IsNullOrEmpty(Id) ? string.Format(@"id=""{0}""", Id) : ""; output.Content.AppendHtml(string.Format(template, modalContext.Heading.GetSectionContent("panel-heading"), modalContext.Body.GetSectionContent("panel-body"), modalContext.Footer.GetSectionContent("panel-footer"), cssClass, idAttr)); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var contentModel = context.SetItem <ModalTagHelper, BasicContext>(); await output.GetChildContentAsync(); var template = @"<div class=""modal fade"" id=""{0}"" tabindex=""-1"" role=""dialog""> <div class=""modal-dialog"" role=""document""> <div class=""modal-content""> {1} {2} {3} </div> </div> </div>"; var content = string.Format(template, Identifier, contentModel.Heading.GetSectionContent("modal-header"), contentModel.Body.GetSectionContent("modal-body"), contentModel.Footer.GetSectionContent("modal-footer")); output.Content.AppendHtml(content); }