#Inserting generated HTML into heex liveview

5 messages · Page 1 of 1 (latest)

fresh yew
#

I'm using earmark to generate HTML from some markdown, but the generated html is showing up as text rather than html elements on the page. This is an a .heex for liveview

markdown = "# Hello\nWorld"

<div>
  <%= Earmark.as_html!(markdown) %>
</div>

becomes attached image

Is there a way I can tell it to treat it as HTML rather than a value? Thanks in advance! Done some googling but haven't had any luck when it comes to doing this with liveview 😦

analog forge
#

yep, to treat as raw value you use the raw function:

<%= raw(Earmark.as_html!(markdown)) %>
fresh yew
#

im an idiot and ur a genius, sorry for not googling hard enough!!!! thank you!!!!!!!!!!!!!!

analog forge
#

lol, no worries!