zhaolei
2020-11-20 921de2254ff5712a44ed8575ee8efe34252f6603
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Microsoft.AspNetCore.Razor.TagHelpers;
 
namespace Prow.Web.Mvc.TagHelpers
{
    /// <summary>
    /// 条件标签类
    /// </summary>
    [HtmlTargetElement(Attributes = "asp-condition", TagStructure = TagStructure.NormalOrSelfClosing)]
    public class ConditionTagHelper : TagHelper
    {
        /// <summary>
        /// 获得/设置 标签生成条件
        /// </summary>
        [HtmlAttributeName("asp-condition")]
        public bool Condition { get; set; }
 
        /// <summary>
        /// 标签处理方法
        /// </summary>
        /// <param name="context"></param>
        /// <param name="output"></param>
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (!Condition) output.SuppressOutput();
        }
    }
}