If block TagHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HtmlTargetElement("*", Attributes = "[asp-if]")] | |
public class IfTagHelper : TagHelper | |
{ | |
/// <summary> | |
/// Shows the element when this condition is true | |
/// </summary> | |
[HtmlAttributeName("asp-if")] | |
public bool IsTrue { get; set; } = true; | |
public override void Process(TagHelperContext context, TagHelperOutput output) | |
{ | |
if (!IsTrue) | |
{ | |
output.TagName = null; | |
output.Content.Clear(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment