Module: Monologue::HtmlHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/monologue/html_helper.rb
Instance Method Summary collapse
-
#activable_li_tag(*url, &block) ⇒ Object
li
tag with the ‘active’ class added if the url is the current one. -
#activable_li_tag_with_link(title, *url) ⇒ Object
li
tag with the ‘active’ class added if the url is the current one with a link inside it pointing to that url. - #sidebar_section_for(title, &block) ⇒ Object
Instance Method Details
#activable_li_tag(*url, &block) ⇒ Object
li
tag with the ‘active’ class added if the url is the current one. Eg.:
<%= activable_li_tag users_path do %>
<%= link_to "Users", users_path %>
<% end %>
12 13 14 |
# File 'app/helpers/monologue/html_helper.rb', line 12 def activable_li_tag(*url, &block) content_tag :li, capture(&block), :class => ("active" if url.any?{|u| current_page?(u)}) end |
#activable_li_tag_with_link(title, *url) ⇒ Object
li
tag with the ‘active’ class added if the url is the current one with a link inside it pointing to that url.
<%= activatable_li_tag_with_link "Users", users_path %>
21 22 23 24 25 |
# File 'app/helpers/monologue/html_helper.rb', line 21 def activable_li_tag_with_link(title, *url) activable_li_tag *url do link_to(title, url.first) end end |
#sidebar_section_for(title, &block) ⇒ Object
27 28 29 30 31 32 |
# File 'app/helpers/monologue/html_helper.rb', line 27 def (title, &block) content_tag(:section, class: 'widget') do content_tag(:header, content_tag(:h1, title)) + capture(&block) end end |