Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
tidying up html output
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkkelly committed Nov 28, 2010
1 parent 665059a commit d58e6d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions lib/navigation/tags/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class NavTagError < StandardError; end
css_class = [("current" if tag.locals.page == root), "first"].compact
first_set = true

tree << %{<li class="#{css_class.join(' ') unless css_class.empty?}" id="#{(root.slug == '/' ? 'home' : root.slug) if tag.attr['ids_for_lis']}">}
tree << %{<a href="#{root.url}" id="link_#{(child_page.slug == '/' ? 'home' : root.slug) if tag.attr['ids_for_links']}">}
tree << %{<li#{" class='#{css_class.join(' ')}'" unless css_class.empty?}#{" id='#{(root.slug == '/' ? 'home' : root.slug)}'" if tag.attr['ids_for_lis']}>}
tree << %{<a href="#{root.url}"#{" id='link_#{(child_page.slug == '/' ? 'home' : root.slug)}'" if tag.attr['ids_for_links']}>}
tree << %{#{root.breadcrumb}}
tree << %{</a></li>}
end
Expand All @@ -53,16 +53,23 @@ class NavTagError < StandardError; end
end
end

['only','except','expand_all','include_root'].each do |key| #'root','depth'
tag.attr.delete(key)
end

tag.attr.delete('only')
tag.attr.delete('except')

if tag.attr
html_options = tag.attr.stringify_keys
tag_options = tag_options(html_options)
else
tag_options = nil
end

%{<ul#{tag_options}>
%{<ol#{tag_options}>
#{tree}
</ul>}
</ol>}

end

Expand Down
4 changes: 2 additions & 2 deletions lib/navigation/tags/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def sub_nav(tag, child_page, depth, first_set = false)
css_class << "parent_of_current" if current_page.url.starts_with?(child_page.url) and current_page != child_page
css_class.compact!

r = %{<li class="#{css_class.join(' ') unless css_class.empty?}" id="nav_#{child_page.slug if tag.attr['ids_for_lis']}">}
r << %{<a href="#{child_page.url}" id="link_#{(child_page.slug == '/' ? 'home' : child_page.slug) if tag.attr['ids_for_links']}">}
r = %{<li#{" class='#{css_class.join(' ')}'" unless css_class.empty?}#{" id='nav_#{child_page.slug}'" if tag.attr['ids_for_lis']}>}
r << %{<a href="#{child_page.url}"#{" id='link_#{(child_page.slug == '/' ? 'home' : child_page.slug)}'" if tag.attr['ids_for_links']}>}
r << %{#{child_page.breadcrumb}}
r << %{</a>}

Expand Down

0 comments on commit d58e6d9

Please sign in to comment.