simple-navigation
simple-navigation copied to clipboard
Posibility insert string before and after link
From issue https://github.com/codeplant/simple-navigation/issues/132
Example (custom renderer):
class ContentListRenderer < SimpleNavigation::Renderer::List
private
def list_content(item_container)
item_container.items.map { |item|
li_options = item.html_options.except(:link)
li_content = tag_for(item)
li_content = item.content_before + li_content + item.content_after
if include_sub_navigation?(item)
li_content << render_sub_navigation_for(item)
end
content_tag(:li, li_content, li_options)
}.join
end
end
and in navigation (bootstrap list group):
SimpleNavigation::Configuration.run do |navigation|
navigation.items do |m|
m.dom_class = 'list-group'
m.item :approval_list, 'List, '',
html: { class: 'list-group-item' },
content_after: "<span class=\"badge\">1234</span>".html_safe,
link_html: {
data: {
push: true,
target: '#messages .area-content'
}
}
end
end
Hi @havran and thank you for your PR.
Could you rename html_before
and html_after
to content_before
and content_after
? It would be clearer next to html_opts
.
An can you write the related tests?
Thank you 😊