-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor RenderFragment to String #22266
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
Comments
@sps014 thanks for contacting us. There is no way to do this today within Blazor. We have support for this in the form of prerendering, but not anywhere else. It is unlikely we add something like this, since we haven't receive similar asks for it yet. |
In your component have a
In |
That worked ... Thanks.. |
@javiercn any plan to override ToString Method of RenderFragment in Future? |
@sps014 no. RenderFragment is also a delegate type, so I don't think that's even possible. |
Oops didn't know that.. i am closing this issue for now as i have other workarounds to deal with the current problem. |
For what it's worth I would like to be able to access the the content of a tag/component as a string rather than a render fragment. In my case I am trying to make a component that simply passes markdown content to HTML. My desired <div class="some-container">
@Html
</div>
@code {
[Parameter]
public RenderFragment ChildContent { get; set; }
public string Html => Markdig.Markdown.ToHtml(this.ChildContent.ToString());
} How I would use it: <div class="foo">
<Markdown>
## A Header of some description
Paragraph 1
Paragraph 2
</Markdown>
</div> Passing that as a parameter just feels dirty and I think I would prefer to just write the HTML at that point. |
I have Blazor Component as
now i am using component as
I want to show RenderFragment as String, not as evaluated Dom Element.
Actual Output
Expected Output
My different Approach
If the component was designed to take string
Use string as Parameter but with this there come many problems like escaping
"
, Visually Ugly looking Component Code, etc. Overall Complexity is increased.I am hoping for a way to convert RenderFragment to string as current implementation gives evaluated Component.
Thank you.
The text was updated successfully, but these errors were encountered: