I'm storing raw html from a contenteditable tag in my RethinkDB database. Now I want to display the content after retrieving it.
html.eex
<div id="contentEditableText">
<%= for %{"contentText" => contentText} <- @contentText.data do %>
<div><%= "#{contentText}" %></div>
<% end %>
</div>
I can sucessfully retrieve it, but it's displaying the raw html itself.
What is required to display Raw HTML code on a Webpage? In order to display HTML code on a webpage, you need to get rid of start tag < and end tag > symbol of every tag in your HTML code.
Raw HTML can be rendered in Blazor by using the MarkupString. You can set the raw HTML as a string to any parameter and cast it in a markup string.
append(html); When this code runs, the refer_summary variable actually contains a string which may contain HTML tags such as <b> , <i> etc., however, those tags are displayed on the page instead of rendering their behavior. For example, on the page it would show <b> rather actually making the content bold.
The phoenix_html
library provides a raw/1 function for this case. phoenix_html
is included by default so you should just need to do:
<div id="contentEditableText">
<%= for %{"contentText" => contentText} <- @contentText.data do %>
<div><%= raw(contentText) %></div>
<% end %>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With