dotnet / dotnet/AspNetCore.Docs

ConditionTagHelper has a few problems

Open
#28,861 0 comments 0 reactions 0 assignees View on GitHub
doc-idea Pri3 Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

The `ConditionTagHelper` looks useful, but the code and documentation is not well written.

* The **Condition** property is not intuitive and could lead to coding errors and developer confusion in production. Setting **Condition** to "true" will _suppress_ rather than render the content, which runs counter to how a conditional is normally interpreted. A better way to express this concept would be to use "Except" or "Unless" which implies the item will be rendered except/unless the value is true.
* The bold text in the sample should probably have been **not** rather than "@Model.Approved". As currently written, the sample will not produce a valid sentence in English. This looks like an unintended search/replace error to me.

```
This website has @Model.Approved been approved yet.
```

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: 19ecfbee-8b84-9ef2-65b6-8c2542f6370f
* Version Independent ID: 9a0cbaa2-65c9-1618-1003-5fd2e7f6192f
* Content: [Author Tag Helpers in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-7.0)
* Content Source: [aspnetcore/mvc/views/tag-helpers/authoring.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/mvc/views/tag-helpers/authoring.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-mvc**
* GitHub Login: @Rick-Anderson
* Microsoft Alias: **riande**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.