Hi guyz i want to add content_tag span in my existing function, and i don't know how to add in this function. Here is my helper function
def taxons_tree_products_list_mobile(root_taxon, current_taxon, max_level = 1)
return '' if max_level < 1 || root_taxon.children.empty?
content_tag :ul, class: 'nav nav-pills nav-stacked' do
root_taxon.children.map do |taxon|
content_tag :li do
link_to (taxon.name, seo_url(taxon)) +
taxons_tree(taxon, current_taxon, max_level - 1)
end
end.join().html_safe
end
end
And this helper function return HTML is something like that
<ul class="nav nav-pills nav-stacked">
<li><a href="/t/categories/bags">Bags</a></li>
<li><a href="/t/categories/mugs">Mugs</a></li>
<li><a href="/t/categories/clothing">Clothing</a></li>
</ul>
But i want HTML like that
<ul class="nav nav-pills nav-stacked">
<li><a href="/t/categories/bags"><span class="pull-right">(50)</span>Bags</a></li>
<li><a href="/t/categories/mugs"><span class="pull-right">(50)</span>Mugs</a></li>
<li><a href="/t/categories/clothing"><span class="pull-right">(50)</span>Clothing</a></li>
</ul>
So please someone help me that how I add this span in my Helper function. I appreciate your help
Thanks
Try this:
content_tag :li do
concat link_to(seo_url(taxon)) do
content_tag(:span, '(50)', class: 'pull-right') + taxon.name
end
concat taxons_tree(taxon, current_taxon, max_level - 1)
end
UPDATE : fixed the code. I don't know what taxons_tree(...)
code returns, but for correct working it should be some string value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.