I need to achieve like below
<MyTagList>
<MyTag></MyTag>
<MyTag></MyTag>
</MyTagList>
When ever I use MyTag
in design time, it need to be enclosed automaticaly by MyTagList
or MyTag
should error that it must be enclosed by MyTagList
You can't do this today at design time. You can however do it partially at runtime by utilizing
TagHelperContext.Items
. By using theItems
property you can ensure that each tag is enclosed by a parent tag and throw if it's not. Insert an indicator into theItems
bag in your parent element and verify that it exists in child elements.As for supporting this in the future there are two issues open to add design time support:
Hope this helps!