I want to render html to the view using the tag helper with the method declared in the helper module, but it doesn't work. html code I'd like to render is following:
<span >
<span ></span>
<span >
<%= current_user_active_count %>
</span>
</span>
The code actually written in the helper is below:
tag.span class: "flex w-5 h-5 ml-3" do
tag.span class: "animate-ping inline-flex h-full w-full rounded-full aspect-square bg-indigo-400 opacity-75"
tag.span current_user_active_count, class: "relative inline-flex w-5 h-5 rounded-full bg-indigo-500 text-gray-200 justify-center aspect-square right-5"
end
The html rendered by this code is below:
<span >
<span >
<%= current_user_active_count %>
</span>
</span>
As shown above, the first tag of the two nested tags is ignored and only the second tag is rendered.
I think it's a writing style problem, but how can I render the desired html?
I would appreciate it if you could advise me.
CodePudding user response:
You can use concat
to accumulate content into the output buffer:
tag.span class: "flex w-5 h-5 ml-3" do
concat tag.span(class: "animate-ping inline-flex h-full w-full rounded-full aspect-square bg-indigo-400 opacity-75")
concat tag.span(current_user_active_count, class: "relative inline-flex w-5 h-5 rounded-full bg-indigo-500 text-gray-200 justify-center aspect-square right-5")
end