Files
nairobi/app/helpers/link_list_helper.rb
Javi Martín 7c4515d6ce Simplify code to generate "See more" link
We can skip the `link_to(*options) if options` part if we accept anchor
tags in the `link_list` helper.
2021-02-02 20:05:40 +01:00

18 lines
434 B
Ruby

module LinkListHelper
def link_list(*links, **options)
return "" if links.select(&:present?).empty?
tag.ul(options) do
safe_join(links.select(&:present?).map do |text, url, current = false, **link_options|
tag.li(({ "aria-current": true } if current)) do
if url
link_to text, url, link_options
else
text
end
end
end, "\n")
end
end
end