If I add [RequiredIf(... to a property I have on a view model class, MVC adds certain data-required... attributes to the resulting mark-up for that property.
I want to do the same; I want to decorate a property of my view model class with [MyMarkup] and have it render data-my-attribute on the rendered HTML for that property's editor.
I have looked high and low for a solution, and haven't found one, which leads me to suspect my approach may be wrong.
What I've Tried
I've tried extending Attribute but can't see how I'd access mark-up in there, since attributes wouldn't generally be concerned with mark-up.
I also looked into data annotations and metadata-aware implementations too, but can't find anything that would allow me to add a data attribute to an element.
Is this possible at all?
Please Note
I'm aware of HTML helpers and that I can pass in custom attributes to them, but I want to keep this as an attribute.