Files
8357WMS/src/WalkingTec.Mvvm.TagHelpers.LayUI/CodeTagHelper.cs
T
2023-07-25 19:20:18 +08:00

30 lines
928 B
C#

using Microsoft.AspNetCore.Razor.TagHelpers;
namespace WalkingTec.Mvvm.TagHelpers.LayUI
{
[HtmlTargetElement("wt:code", TagStructure = TagStructure.NormalOrSelfClosing)]
public class CodeTagHelper : BaseElementTag
{
public new int? Height { get; set; }
public string Title { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "pre";
output.Attributes.SetAttribute("class", "layui-code");
output.Attributes.SetAttribute("encode", true);
if (Height.HasValue)
{
output.Attributes.SetAttribute("lay-height", $"{Height}px");
}
if (string.IsNullOrEmpty(Title) == false)
{
output.Attributes.SetAttribute("lay-title", Title);
}
base.Process(context, output);
}
}
}