Answer the question
In order to leave comments, you need to log in
How to wrap links in a list in ruby?
Need to wrap in a list of ul > li links. Initially, the link output code looks like this:
def links_to_hashtags(hashtags = object.hashtags)
hashtags.map(&:to_s).map do |hashtag|
# XXX transitional
url = h.hashtag_page_enabled? && h.logged_out? ? h.tag_path(hashtag.downcase) : h.hashtag_friends_path(q: hashtag.downcase)
h.link_to "##{hashtag}", url, dir: h.html_dir(hashtag)
end.join(' ').html_safe
end
def links_to_hashtags(hashtags = object.hashtags)
hashtags.map(&:to_s).map do |hashtag|
# XXX transitional
url = h.hashtag_page_enabled? && h.logged_out? ? h.tag_path(hashtag.downcase) : h.hashtag_friends_path(q: hashtag.downcase)
h.content_tag :ul, class: 'fancy' do
h.concat h.content_tag :li,
h.link_to "##{hashtag}", url, dir: h.html_dir(hashtag)
end.join(' ').html_safe
end
Answer the question
In order to leave comments, you need to log in
content_tag :ul, class: 'fancy' do
hashtags.map(&:to_s).map do |hashtag|
# XXX transitional
url = h.hashtag_page_enabled? && h.logged_out? ? h.tag_path(hashtag.downcase) : h.hashtag_friends_path(q: hashtag.downcase)
content_tag :li do
link_to "##{hashtag}", url, dir: h.html_dir(hashtag)
end
end.join.html_safe
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question