Module: Monologue::HtmlHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/monologue/html_helper.rb

Instance Method Summary collapse

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)
   :li, capture(&block), :class => ("active" if url.any?{|u| current_page?(u)})
end

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


27
28
29
30
31
32
# File 'app/helpers/monologue/html_helper.rb', line 27

def sidebar_section_for(title, &block)
  (:section, class: 'widget') do
    (:header, (:h1, title)) +
        capture(&block)
  end
end