Partial views as tag helpers for Razor Pages
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
The `` tag helper works OK for partial views that take a single parameter, but it requires hacks like using a tuple as the model (which isn't particularly readable and can have type conversion issues) when the partial view needs multiple parameters.
### Describe the solution you'd like
It would be great if a custom tag helper could be defined by using a Razor Pages-style object model. For example, suppose that the file FooBar.cshtml was placed into the TagHelpers folder with the following code:
```
@tagHelper "foo-bar"
@model FooBarModel
First Thing: @Model.FirstThing
Second Thing: @Model.SecondThing
```
Suppose that it had a code-behind file FooBar.cshtml.cs as follows
```
public class FooBarModel
{
[TagHelperProperty("first-thing")]
public string FirstThing { get; set; }
[TagHelperProperty("second-thing")]
public string SecondThing { get; set; }
}
```
If a Razor Page invoked the tag helper as follows:
```
```
Then, the result would be rendered as follows:
```
First Thing: ABC
Second Thing: XYZ
```
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.