Skip to content

zenima/taghelpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zenima.TagHelpers library

This library provides additional TagHelpers for ASP.NET Core that can be used to write cleaner code in Razor.

GitHub tag (latest SemVer) GitHub

Usage

You can install the TagHelpers using the following command.

dotnet add package Zenima.TagHelpers

To be able to use it in your Razor views, you have to reference it in the _ViewImports.cshtml file by adding the following line:

@addTagHelper *, Zenima.TagHelpers

New TagHelpers

DisplayTagHelper

Can be used on any existing tag.

Attribute Functionality
display Enable/disable tag visibility
display-wrapper Enable/disable wrapper tag visibility

display

Example:

<div display="@User.LoggedIn()">
  <span>Welcome @User.Name</span>
</div>

display-wrapper

Example:

<a href="@item.Url" display-wrapper="@item.ShowLink">
  <span>@item.Name</span>
</a>