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

Discussion: Breaking changes for tag helper authors in RC1 #583

Closed
NTaylorMullen opened this issue Oct 22, 2015 · 3 comments
Closed

Discussion: Breaking changes for tag helper authors in RC1 #583

NTaylorMullen opened this issue Oct 22, 2015 · 3 comments
Milestone

Comments

@NTaylorMullen
Copy link

Due to the new TagHelper addition of Init used to setup your TagHelperContext and other related item bag info for executed children to consume we decided that the ability to execute children doesn't entirely make sense on the context object since it has no connection to the actual structure of the element.

The alternative would have been to make GetChildContentAsync throw when invoked within the Init method (yuck).

Before

public class CustomTagHelper : TagHelper
{
    public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
    {
        await context.GetChildContentAsync();
    }
}

After

public class CustomTagHelper : TagHelper
{
    public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
    {
        await output.GetChildContentAsync();
    }
}
@thoemmi
Copy link

thoemmi commented Oct 23, 2015

Though I see the rationale behind the change, it seems strange to call output for the input. 😕

@dougbu
Copy link
Contributor

dougbu commented Oct 23, 2015

seems strange to call output for the input. 😕

This delegate returns the output of the child elements. In MVC tag helpers that use this for example, the return value is often not used -- it's just called to ensure children have executed (and output whatever they're going to output).

@dougbu dougbu changed the title Discussion: TagHelperContext.GetChildContentAsync moved to TagHelperOutput Discussion: Breaking changes for tag helper authors in RC1 Oct 23, 2015
@dougbu
Copy link
Contributor

dougbu commented Oct 23, 2015

Broadening the subject to include additional changes. Please use this issue to discuss aspnet/Announcements#89 as well as aspnet/Announcements#90.

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

No branches or pull requests

4 participants