Update garnish and render_doc functions

Now all element node attributes have to be threaded through the
eph.attributes which is done by the garnish function.
This commit is contained in:
Thelonius Kort
2023-01-19 13:48:56 +01:00
parent 170883490f
commit 078db6e38e
3 changed files with 23 additions and 31 deletions

View File

@ -11,9 +11,7 @@ defmodule OutlookWeb.HtmlDocComponent do
def render_doc(%{tunit_tag: _} = assigns) do
~H"""
<%= for node <- @tree do %>
<.dnode node={node} tunit_tag={@tunit_tag} />
<% end %>
<.dnode :for={node <- @tree} node={node} tunit_tag={@tunit_tag} />
"""
end
def render_doc(assigns) do
@ -24,9 +22,8 @@ defmodule OutlookWeb.HtmlDocComponent do
def dnode(%{node: %{status: status}} = assigns) do
~H"""
<.dynamic_tag name={@tunit_tag} class="tunit" nid={@node.nid} {Map.get(@node.eph, :attributes, %{})}>
<%= @node.content |> raw %>
</.dynamic_tag>
<.dynamic_tag name={@tunit_tag} nid={@node.nid} {Map.get(@node.eph, :attributes, %{})}
><%= @node.content |> raw %></.dynamic_tag>
"""
end
@ -38,11 +35,9 @@ defmodule OutlookWeb.HtmlDocComponent do
def dnode(assigns) when assigns.node.type == :element do
~H"""
<.dynamic_tag name={@node.name} nid={@node.nid} {@node.attributes |> Map.merge(Map.get(@node.eph, :attributes, %{}))}>
<%= for child_node <- @node.content do %>
<.dnode node={child_node} tunit_tag={@tunit_tag} />
<% end %>
</.dynamic_tag>
<.dynamic_tag name={@node.name} nid={@node.nid} {Map.get(@node.eph, :attributes, %{})}
><.dnode :for={child_node <- @node.content} node={child_node} tunit_tag={@tunit_tag}
/></.dynamic_tag>
"""
end