Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Tag Helpers: Add enum attribute support. #196

Closed
NTaylorMullen opened this issue Oct 15, 2014 · 11 comments
Closed

Tag Helpers: Add enum attribute support. #196

NTaylorMullen opened this issue Oct 15, 2014 · 11 comments
Assignees
Milestone

Comments

@NTaylorMullen
Copy link
Member

Right now if a TagHelper has an Enum property the user has to type in the full Enum value:

<mytaghelper someattr="MyEnum.Foo" />

We can simplify this and make it:

<mytaghelper someattr="Foo" />

By assuming the Enum.

@rynowak
Copy link
Member

rynowak commented Nov 20, 2014

See TODO in the MVC repro in ValidationSummaryTagHelper for a string that should be changed to an enum when this is fixed.

@yishaigalatzer yishaigalatzer modified the milestones: Backlog, 4.0.0-rc1 Nov 26, 2014
@DamianEdwards
Copy link
Member

We discussed this again and can't find a reason not to do it and it it's a nice improvement.

@NTaylorMullen
Copy link
Member Author

Note: we should also add the @ override to not specify the MyEnum. automagically (like we do for ModelExpressions today).

@DamianEdwards
Copy link
Member

Agreed

@ghost
Copy link

ghost commented May 25, 2015

nit: missing issue tag TagHelper.

@Eilon Eilon modified the milestones: 4.0.0-beta6, 4.0.0-beta7 Jul 1, 2015
@Eilon Eilon modified the milestones: 4.0.0-rc1, 4.0.0-beta8 Sep 24, 2015
@Eilon Eilon modified the milestones: 4.0.0-rc1, 4.0.0-rc2 Oct 22, 2015
@NTaylorMullen NTaylorMullen self-assigned this Oct 26, 2015
NTaylorMullen added a commit that referenced this issue Oct 27, 2015
- If a `TagHelper` attribute is an `enum` then you no longer need to provide the `enum` name. To override this functionality you can add the `@` symbol.
- Added code generation tests.
- Added `TagHelperDescriptorFactoryTest`s that double for Precompilation tests.

#196
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue Oct 28, 2015
- Razor `TagHelper`s now special case `enum` values so you don't need to provide the entire `enum` prefix.
NTaylorMullen added a commit to aspnet/RazorTooling that referenced this issue Oct 28, 2015
- Add new `IsEnum` `TagHelperDescriptor` property to VS compatibility test.
NTaylorMullen added a commit to aspnet/RazorTooling that referenced this issue Oct 28, 2015
- Add new `IsEnum` `TagHelperDescriptor` property to VS compatibility test.
NTaylorMullen added a commit that referenced this issue Oct 29, 2015
- If a `TagHelper` attribute is an `enum` then you no longer need to provide the `enum` name. To override this functionality you can add the `@` symbol.
- Added code generation tests.
- Added `TagHelperDescriptorFactoryTest`s that double for Precompilation tests.

#196
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue Oct 29, 2015
- Razor `TagHelper`s now special case `enum` values so you don't need to provide the entire `enum` prefix.
@NTaylorMullen
Copy link
Member Author

NTaylorMullen added a commit to aspnet/MusicStore that referenced this issue Oct 29, 2015
- `TagHelper`s now auto-fill enums. Updated files to reflect new auto-filling enum changes.
NTaylorMullen added a commit to aspnet/RazorTooling that referenced this issue Oct 30, 2015
- Add new `IsEnum` `TagHelperDescriptor` property to VS compatibility test.
@tomshane
Copy link

tomshane commented Aug 23, 2017

Is it possible to convert enum value names to lower case when used in html? The same way how tags and attributes are converted, so it is more inline with html conventions.

enum Type { Number, Text }

To be used like:

<tag type="number"/>

@NTaylorMullen
Copy link
Member Author

@R74NN sorry it is not. The values exposed in the attributes today are pure C# so they must match.

If you'd like to work around it in your own implementations you can always have HTML specific enums with lower case names that you interop between.

@DamianEdwards
Copy link
Member

It would certainly be possible to modify the code gen to lowercase enum value names. We don't have a great extensibility point for that today, but it might be feasible with a tree rewriter. We could investigate adding some kind of option for this in the future but I think it would likely be part of a more in depth set of features enabling customization of bound property code generation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants