protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); var sequence = 0; builder.OpenElement(sequence++, "div"); builder.AddAttribute(sequence++, "id", Id); builder.OpenElement(sequence++, "span"); builder.AddAttribute(sequence++, "class", "iconify"); builder.AddAttribute(sequence++, "data-icon", Icon); builder.AddAttribute(sequence++, "data-inline", "false"); if (Width.IsNotNullOrWhiteSpace()) { builder.AddAttribute(sequence++, "data-width", Width); } if (Height.IsNotNullOrWhiteSpace()) { builder.AddAttribute(sequence++, "data-height", Height); } if (Rotation != 0) { builder.AddAttribute(sequence++, "data-rotate", $"{Rotation}deg"); } if (!IsInline) { builder.AddAttribute(sequence++, "data-inline", "false"); } builder.AddAttribute(sequence++, "style", Styles.ToString()); builder.AddMultipleAttributes(sequence, CustomAttributes); builder.CloseElement(); builder.CloseElement(); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var hasColon = Title?.Trim() != "~"; var td = new StringBuilder($"<td>{Title + (hasColon ? ":" : "")}</td><td{(ColSpan.HasValue ? $" colspan='{ColSpan}'" : "")}>"); if (ContentTag != null) { var innerOutput = CreateTagHelperOutput(); if (Field.IsNotNullOrWhiteSpace()) { innerOutput.Attributes.Add("name", Field.ToCamelCase()); } var css = ""; if (Height.IsNotNullOrWhiteSpace()) { css += $"height: {Height};"; } if (Width.IsNotNullOrWhiteSpace()) { css += $"width: {Width};"; } if (MinWidth.IsNotNullOrWhiteSpace()) { css += $"min-width: {MinWidth};"; } if (ColSpan > 1 && Width.IsNullOrWhiteSpace()) { css += "width: 100%;"; } if (css != "") { innerOutput.Attributes.Add("style", css); } var innerTagContent = await RenderInnerTagHelper(ContentTag, context, innerOutput); td.Append(innerTagContent); } else { var content = await output.GetChildContentAsync(); td.Append(content.GetContent()); if (Field.IsNotNullOrWhiteSpace()) { var doc = ParseHtml(ChildContent); var contentElement = doc.Body.FirstElementChild; contentElement.SetAttribute("name", Field.ToCamelCase()); ChildContent = contentElement.OuterHtml; } td.Append(ChildContent); } if (Sort.HasValue) { output.Attributes.Add(EasyuiConsts.Item_Sort, Sort); } if (ReplaceField.IsNotNullOrWhiteSpace()) { output.Attributes.Add(EasyuiConsts.Item_Replace, ReplaceField); } td.Append("</td>"); output.Content.AppendHtml(td.ToString()); await base.ProcessAsync(context, output); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var hasColon = Title?.Trim() != "~"; //var td = new StringBuilder($"<td>{Title + (hasColon ? ":" : "")}</td><td{(ColSpan.HasValue ? $" colspan='{ColSpan}'" : "")}>"); var md = ColMd > 12 ? 12 : ColMd; var colspan = ColSpan > 0 ? $" {LayuiConsts.Colspan}='{ColSpan}' " : ""; var sort = Sort.HasValue ? $" {LayuiConsts.Item_Sort}='{Sort}' " : ""; var title = Title.IsNotNullOrWhiteSpace() ? $"<label class='layui-form-label'>{Title}</label>" : ""; var replace = ReplaceField.IsNotNullOrWhiteSpace() ? $" {LayuiConsts.Item_Replace}='{ReplaceField}' " : ""; if (ColSpan > 0) { md = md * ColSpan.Value; } var div = new StringBuilder($"<div class='layui-form-item layui-col-md{md}'{colspan}{sort}{replace}>{title}<div class='layui-input-block'>"); if (ContentTag != null) { var innerOutput = CreateTagHelperOutput(); if (Field.IsNotNullOrWhiteSpace()) { innerOutput.Attributes.Add("name", Field.ToCamelCase()); } var css = ""; if (Height.IsNotNullOrWhiteSpace()) { css += $"height: {Height};"; } if (Width.IsNotNullOrWhiteSpace()) { css += $"width: {Width};"; } if (MinWidth.IsNotNullOrWhiteSpace()) { css += $"min-width: {MinWidth};"; } if (ColSpan > 1) { css += "width: 100%;"; } if (css != "") { innerOutput.Attributes.Add("style", css); } var innerTagContent = await RenderInnerTagHelper(ContentTag, context, innerOutput); div.Append(innerTagContent); } else { var content = await output.GetChildContentAsync(); div.Append(content.GetContent()); div.Append(ChildContent); } if (Sort.HasValue) { output.Attributes.Add(LayuiConsts.Item_Sort, Sort); } if (ReplaceField.IsNotNullOrWhiteSpace()) { output.Attributes.Add(LayuiConsts.Item_Replace, ReplaceField); } div.Append(" </div> </div>"); output.Content.AppendHtml(div.ToString()); await base.ProcessAsync(context, output); }