Showing
2 changed files
with
7 additions
and
3 deletions
| @@ -47,9 +47,11 @@ module Kanjai | @@ -47,9 +47,11 @@ module Kanjai | ||
| 47 | when 'text' | 47 | when 'text' |
| 48 | content = item[:source].to_s.strip | 48 | content = item[:source].to_s.strip |
| 49 | if current_page | 49 | if current_page |
| 50 | + is_current_page = session[:url] == current_page.menu_url(session[:scheme], I18n.locale).gsub("/#{I18n.locale}", "") | ||
| 51 | + | ||
| 50 | content = content.gsub('###link###', current_page.menu_url(session[:scheme], lang = nil).to_s) | 52 | content = content.gsub('###link###', current_page.menu_url(session[:scheme], lang = nil).to_s) |
| 51 | .gsub('###title###', current_page.lang_attributes(I18n.locale, :title).to_s) | 53 | .gsub('###title###', current_page.lang_attributes(I18n.locale, :title).to_s) |
| 52 | - .gsub('###active_class###', 'active') | 54 | + .gsub('###active_class###', is_current_page ? 'active' : '') |
| 53 | end | 55 | end |
| 54 | subparts << content | 56 | subparts << content |
| 55 | when 'repeat' | 57 | when 'repeat' |
| @@ -159,10 +161,12 @@ module Kanjai | @@ -159,10 +161,12 @@ module Kanjai | ||
| 159 | else | 161 | else |
| 160 | attributes = item[:attributes] | 162 | attributes = item[:attributes] |
| 161 | if current_page | 163 | if current_page |
| 164 | + is_current_page = session[:url] == current_page.menu_url(session[:scheme], I18n.locale).gsub("/#{I18n.locale}", "") | ||
| 165 | + | ||
| 162 | attributes = replace_attributes_marker(attributes, { | 166 | attributes = replace_attributes_marker(attributes, { |
| 163 | '###link###' => current_page.menu_url(session[:scheme], lang = nil), | 167 | '###link###' => current_page.menu_url(session[:scheme], lang = nil), |
| 164 | '###title###' => current_page.lang_attributes(I18n.locale, :title), | 168 | '###title###' => current_page.lang_attributes(I18n.locale, :title), |
| 165 | - '###active_class###' => 'active' | 169 | + '###active_class###' => is_current_page ? 'active' : '' |
| 166 | }) | 170 | }) |
| 167 | end | 171 | end |
| 168 | subparts.send(item[:name].to_s, attributes) do |next_subparts| | 172 | subparts.send(item[:name].to_s, attributes) do |next_subparts| |