Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor rendering - joining multiple MarkupStrings together with unclosed HTML elements

$
0
0

Im curently rewriting old WebForms app to Blazor InteractiveServerApp (.NET 9). This app is reading and processing static template ".htm" files, that contains partial HTML markups and custom "internal" markups. For example how that file can look like:

MyCustomTemplate.htm

<table><tr><td>      [MySpecialTagToBeTranslated]</td></tr></table>

The idea is to give customers (implementation partners) ability to change the frontend freely as they need. The custom markup is then used to hide the complex code and binding logic behind "simpler" tag.

So, after processing that template, I have something like this:

ProcessingControl.razor

@((MarkupString)"<table><tr><td>")@RenderProcessedControl (translates to "<label>My processed content</label>")@((MarkupString)"</td></tr></table>")@code {// RenderFragment to build the controlsprivate RenderFragment RenderProcessedControl() => builder =>{    builder.OpenComponent<MySpecialTagToBeTranslated>(0);    builder.CloseComponent();    ... etc};}

The idea in this example is to have "My processed content" from component inside "" tag. But the final result in browser is:

<table><tr><td></td></tr></table><label>My processed content</label>

Is there a solution that I can apply to make this work? Thank you.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>