We can skip the `link_to(*options) if options` part if we accept anchor tags in the `link_list` helper.
18 lines
434 B
Ruby
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
|