Component Renderer for non-blazor WebASsembly #56986
-
I am using wasm-browser project template to basically build a custom client-side MVC framework. I leverage a RCL to render *.razor templates to HTML client side by using HtmlRenderer. Simplified, it is essentially doing this:
The one thing this doesn't support is I tried using I had some success with a custom renderer, but I'm not clear how to do the final render to HTML since the type it returns is no longer a RootHtmlComponent with .ToHtmlString(), and generally feels like I probably have implemented aspects incorrectly.
I started to look through existing ASP.NET Core renderer's (that inherit from Microsoft.AspNetCore.Components.RenderTree.Render), but having a hard time wrapping my head around all the options. Is there an existing renderer that would support |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is one of those things where you spend hours, and feel stuck, post a question, and then 10 minutes later you find a solution. It was big thanks to Steve Sanderson for leaving this comment in StaticHtmlRender (I'm so thankful when people actually comment code and don't take for granted that the "why"/rational is implicitly understood):
Based on that I made a full copy of HtmlRender, implemented my own StaticRenderer that returns a completed task:
then changed my custom HtmlRenderer "copy" to use this StaticHtmlWithAfterRenderer. Making a copy of HtmlRenderer doesn't feel exactly like to cleanest thing to do, but not sure how else I would do it without the encapsulated StaticHtmlRenderer not being a template parameter. |
Beta Was this translation helpful? Give feedback.
This is one of those things where you spend hours, and feel stuck, post a question, and then 10 minutes later you find a solution. It was big thanks to Steve Sanderson for leaving this comment in StaticHtmlRender (I'm so thankful when people actually comment code and don't take for granted that the "why"/rational is implicitly understood):