Skip to content

Replace RenderComponentAsync in templates with a new tag helper #13726

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
rynowak opened this issue Sep 5, 2019 · 8 comments
Closed

Replace RenderComponentAsync in templates with a new tag helper #13726

rynowak opened this issue Sep 5, 2019 · 8 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one

Comments

@rynowak
Copy link
Member

rynowak commented Sep 5, 2019

This would look like:

<component type="typeof(App)" render-mode="ServerPrerendered" />

We think this is much simpler and easier to explain. We want to avoid using async methods in Razor where they produce output, in very prominent cases, because there are lots of ways to get it wrong.

We won't delete RenderComponentAsync, the tag helper will call it, or will do the same thing.

@rynowak rynowak added area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Sep 5, 2019
@DamianEdwards
Copy link
Member

Example Tag Helper implementation: https://gist.github.com/DamianEdwards/51c961a1597ec133bd4d5eef30efd9ca

@DamianEdwards
Copy link
Member

Note that we currently don't have a non-generic overload of IHtmlHelper.RenderComponentAsync and we probably should. It would definitely make the Tag Helper much easier to author.

@mkArtakMSFT mkArtakMSFT added this to the 3.1.0-preview1 milestone Sep 6, 2019
@danroth27 danroth27 changed the title Consider replacing RenderComponentAsync in templates with a new tag helper Replace RenderComponentAsync in templates with a new tag helper Sep 7, 2019
@danroth27 danroth27 mentioned this issue Sep 7, 2019
10 tasks
@Stamo-Gochev
Copy link

@rynowak What is the reason behind mixing blazor components and tag helpers? Can this be a blazor component instead?

@DamianEdwards
Copy link
Member

@Stamo-Gochev this is literally the seam between Razor "views" (which means any cshtml file) and Razor Components (any razor file). They both use the Razor language, but use very different build and render pipelines. You can host a Razor Component in a Razor View, but not the other way around. This is about that call-site where you want to render a Razor Component from within a Razor View. Tag Helpers are the way to get HTML-element-like invocation/consumption syntax for APIs in Razor Views, so that's the primitive we'd use to enable a nice syntax for rendering a Razor Component from within a Razor View.

@pranavkm
Copy link
Contributor

Looks like the Component element might become part of the spec: https://www.w3.org/TR/NOTE-HTMLComponents#component although I don't see it being used in a sample in that document. Should we use <component asp-type="..." to disambiguate?

@DamianEdwards
Copy link
Member

Seems that spec is way old and effectively dead (like, from before 2000). Seems we can just continue on the original plan.

@mkArtakMSFT mkArtakMSFT removed this from the 3.1.0-preview3 milestone Oct 1, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.1.0-preview2 milestone Oct 1, 2019
pranavkm pushed a commit that referenced this issue Oct 1, 2019
pranavkm pushed a commit that referenced this issue Oct 2, 2019
@javiercn javiercn assigned pranavkm and unassigned javiercn Oct 8, 2019
@javiercn
Copy link
Member

javiercn commented Oct 8, 2019

@pranavkm Giving this to you as you took over.

pranavkm pushed a commit that referenced this issue Oct 9, 2019
pranavkm pushed a commit that referenced this issue Oct 11, 2019
pranavkm added a commit that referenced this issue Oct 11, 2019
* Introduce ComponentTagHelper
Fixes #13726
@pranavkm pranavkm added Done This issue has been fixed and removed Working labels Oct 11, 2019
@pranavkm
Copy link
Contributor

Fixed as part of d299ae2

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests

6 participants