Skip to content

Commit

Permalink
Display raw html content
Browse files Browse the repository at this point in the history
Display the raw html content with phoenix
  • Loading branch information
SimonLab committed Nov 30, 2022
1 parent a0b1f50 commit 9f8d61c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/app_web/live/app_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ defmodule AppWeb.AppLive do
@impl true
def handle_event("item-updated", %{"content" => content}, socket) do
IO.inspect(content)
content = String.replace(content, "tag", "<span style=\"font-weight: bold\">tag</span>")
{:noreply, assign(socket, item: content )}

content =
String.replace(content, "tag", "<span style=\"color: red\">tag</span>")

{:noreply, assign(socket, item: content)}
end

@impl true
Expand Down
2 changes: 1 addition & 1 deletion lib/app_web/live/app_live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
id="content"
class="h-80 bg-gray-200 w-full my-10 text-slate-800 text-3xl max-h-100 border border-b border-slate-200"
>
<%= @item %>
<%= raw @item %>
</div>
<!-- Want to help "DRY" this? see: https://github.com/dwyl/app-mvp-phoenix/issues/105 -->
<!-- https://tailwindcss.com/docs/justify-content#end -->
Expand Down

0 comments on commit 9f8d61c

Please sign in to comment.