I have this code:
div class: item.ui_type do
link_to image_tag(item.image.image_public_url), item.target)
link_to item.label, item.target
end
Basically, I want a div with 2 links inside. However, only the last element is getting rendered, presumably because what gets rendered inside the body is the return value of the block.
I know I can declare those as an array and join them, but then I need to call html_safe. I'm trying to find a way to do this when you actually don't trust the input that you're receiving.
This seems like it should be an extremely simple thing to do, but I can't find it anywhere.
Any pointers?
I suspect the reason atomdev's example works and Daniel's does not is that link_to
is a Rails tag helper and a
is an Arbre tag, see this similar issue. Try wrapping link_to
with text_node
, div
or span
. It might be worth opening an Arbre GitHub issue for this.
Here's what I did to add two links inside the div
div(:class => "some_class") do
[
link_to("Link1", link1_path),
link_to("Link2", link2_path)
].join.html_safe
end
Behind it does is first, create the link tag in strings inside an array, second, you join these strings and make it html_safe so div can accept it.
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