Skip to content

Make the TagHelperContext available to content of Tag Helpers #4975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DamianEdwards opened this issue Nov 22, 2014 · 0 comments
Closed

Make the TagHelperContext available to content of Tag Helpers #4975

DamianEdwards opened this issue Nov 22, 2014 · 0 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-razor-pages
Milestone

Comments

@DamianEdwards
Copy link
Member

As part of #221, contents of all Tag Helper invocations will now be wrapped in a delegate to allow for conditional execution, retrieval, or even suppresion, of the content by the surround Tag Helper.

This delegate should accept a TagHelperContext tagHelperContext parameter that is passed in by the page and shared with the surrounding TagHelper. When combined with #238, this enables the content to either receive or pass values back to the surrounding Tag Helper (depending on the order of execution).

This feature would be used by the CacheTagHelper (aspnet/Mvc#1552) to enable the contents to add cache invalidation triggers.

e.g.

Tag Helper Declaration

[TagName("my-tag")]
public class MyTagHelper : TagHelper {
    public override void Process(TagHelperContext context, TagHelperOutput output) {
        context.Items["message"] = "This came from the MyTagHelper class!";
    }
}

Consumption

<my-tag>
    Message from the tag helper: @tagHelperContext.Items["message"]
</my-tag>
@NTaylorMullen NTaylorMullen changed the title Tag Helpers: Make the TagHelperContext available to content of Tag Helpers Make the TagHelperContext available to content of Tag Helpers Jan 23, 2015
@aspnet-hello aspnet-hello transferred this issue from aspnet/Razor Dec 14, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 14, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-razor-pages labels Dec 14, 2018
@pranavkm pranavkm added the c label Aug 20, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-razor-pages
Projects
None yet
Development

No branches or pull requests

4 participants