public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var content = await output.GetChildContentAsync(); if (content.IsEmptyOrWhiteSpace) { var span = new HtmlTags.HtmlTag("span") .AddClass("glyphicon glyphicon-plus"); output.Content.SetHtmlContent(span.ToString()); } output.Attributes.SetAttribute("class", "btn btn-success"); }
protected override HtmlTags.HtmlTag Render(Document document, List block) { var ol = new HtmlTags.HtmlTag("ol"); foreach (Item item in block.Items) { var li = new HtmlTags.HtmlTag("li", ol); var itemHtml = this.ParagraphRenderer.Render(document, item).ToHtmlString(); li.AppendHtml(itemHtml.Substring(3, itemHtml.Length - 7)); } return(ol); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.TagName = "div"; output.Attributes.SetAttribute("class", "panel-body"); var content = await output.GetChildContentAsync(); var collectionContext = (InputCollectionContext)context.Items[typeof(InputCollectionTagHelper)]; TextWriter newContent = new StringWriter(); var table = new HtmlTags.HtmlTag("table") .AddClasses("table", "table-striped"); var thead = new HtmlTags.HtmlTag("thead"); var theadRow = new HtmlTags.HtmlTag("tr"); var tbody = new HtmlTags.HtmlTag("tbody") .Attr("data-bind", "foreach: " + collectionContext.Name); var tbodyRow = new HtmlTags.HtmlTag("tr"); newContent.Write(table.NoClosingTag()); newContent.Write(thead.NoClosingTag()); newContent.Write(theadRow.NoClosingTag()); foreach (var contextItem in collectionContext.Items) { newContent.Write("<th>" + contextItem.Label + "</th>"); } newContent.Write("</tr>"); newContent.Write("</thead>"); newContent.Write(tbody.NoClosingTag()); newContent.Write(tbodyRow.NoClosingTag()); var enc = NullHtmlEncoder.Create(new System.Text.Encodings.Web.TextEncoderSettings()); foreach (var contextItem in collectionContext.Items) { newContent.Write("<td>"); contextItem.Content.WriteTo(newContent, enc); newContent.Write("</td>"); } newContent.Write("</tr>"); newContent.Write("</tbody>"); newContent.Write("</table>"); output.Content.SetHtmlContent(newContent.ToString()); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var content = await output.GetChildContentAsync(); output.TagName = "div"; output.Attributes.SetAttribute("class", "form-group clearfix"); var label = new HtmlTags.HtmlTag("label") .AddClasses("control-label", "col-sm-2") .Text(Label); var innerDiv = new HtmlTags.DivTag() .AddClass("col-sm-10"); TextWriter writer = new StringWriter(); writer.WriteLine(label.ToHtmlString()); writer.WriteLine(innerDiv.NoClosingTag().ToHtmlString()); content.WriteTo(writer, NullHtmlEncoder.Create()); writer.WriteLine("</div>"); output.Content.SetHtmlContent(writer.ToString()); }
public static HtmlTags.HtmlTag AddClosedTag(this HtmlTags.HtmlTag tag, string closedagName) { tag.AppendHtml("<" + closedagName + "/>"); return(tag); }