-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Add RenderFragment-like functionality to pure partials and view components in pure Razor SST #40299
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
I am also on server side rendering only camp. By using Turbo from Rails 7 I can have pretty responsive app without all the burden of complicated JS frameworks or Blazor. What I am missing is easy way to reuse render code in templates. |
MVC has never had a component model (like Web Forms or Blazor do), so HTML composition in the ways mentioned above has always been difficult/impossible 😖. If static Blazor is meant to eventually replace classic MVC/Razor Pages style Razor rendering then we'd at least get a component model for our SSR HTML. Otherwise we need something like View Component slots to keep our Razor templates well factored and organized. |
We think we will enable this with components as part of #6348 |
@danroth27 Does this mean developers that are building aspnetcore sites serving server-rendered HTML with View Components and Tag Helpers could weave them in with Razor Components for additional server-rendering flexibility? Would this solution require any aspects of Blazor WASM or would enhanced Blazor server-side rendering be usable without the client-side aspect? |
Yup, that's the idea. Lots of details to work out though, so this could change.
We already have a component tag helper that supports pure server-side rendering via RenderMode.Static, whichout involving Blazor Server or Blazor WebAssembly. The idea is to more deeply integrate using Blazor components for server-side rendering. |
I've explored using the Blazor server-side HTML rendering and ran into all the caveats mentioned by Andrew Lock. Blazor's component model is 👍 so if it could play nice with the existing MVC Razor component pieces (view components/tag helpers), I'm eager to watch developments in that space. |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
Currently it is hard to easily pass HTML content into partial or custom component in Razor Pages or MVC scenarios. If you want to create a server side rendered component for box with header only way is to write custom tag helper.
Razor Components (available with Component Tag Helper with static rendering are not a solution since they don't support HtmlHelper and Tag Helpes (so no linking via
asp-page
or no antiforgery protection in forms).Describe the solution you'd like
Solution proposed in #4901 would be a good start. There is even example implementation in https://github.com/rdlaitila/AspNetCore.Mvc.ViewComponentSlots.
Additional context
Idea for this comes from Ruby on Rails where you can easily create HTML based components by using partial. See 3.4.2 Using Partials to Simplify Views section from Rails manual.
See also https://andrewlock.net/dont-replace-your-view-components-with-razor-components/ for some problems when tryign to convert from View Component into Razor Component.
The text was updated successfully, but these errors were encountered: