The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
875 B

using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System;
using System.Collections.Generic;
using System.Text;
namespace Teknik.Utilities.TagHelpers
{
[HtmlTargetElement(Attributes = "conditional")]
public class ConditionalElementTagHelper : TagHelper
{
[HtmlAttributeName("asp-condition")]
public bool Condition { get; set; }
[HtmlAttributeNotBound]
[ViewContext]
public ViewContext ViewContext { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
base.Process(context, output);
output.Attributes.RemoveAll("conditional");
if (!Condition)
{
output.TagName = string.Empty;
}
}
}
}