the last commit broke the test suite: fixed now

This commit is contained in:
Didier Lafforgue 2012-03-23 00:41:04 +01:00
parent 58c5e9e238
commit e9bf29f297
2 changed files with 19 additions and 16 deletions

View File

@ -56,8 +56,8 @@ module Locomotive
output = children_output.join("\n") output = children_output.join("\n")
if @options[:no_wrapper] != 'true' if @options[:no_wrapper] != 'true'
list_class = !@options[:class].blank? ? %( class="#{@options[:class]}") : '' list_class = !@options[:class].blank? ? %( class="#{@options[:class]}") : ''
output = %{<ul id="#{@options[:id]}"#{list_class}>\n#{output}</ul>} output = %{<ul id="#{@options[:id]}"#{list_class}>\n#{output}</ul>}
end end
output output
@ -90,20 +90,18 @@ module Locomotive
label = %{#{icon if @options[:icon] != 'after' }#{title}#{icon if @options[:icon] == 'after' }} label = %{#{icon if @options[:icon] != 'after' }#{title}#{icon if @options[:icon] == 'after' }}
dropdow = "" link_options = caret = ''
link_options = "" href = "/#{page.fullpath}"
href = "/#{page.fullpath}"
caret = ""
if render_children_for_page?(page, depth) && @options[:bootstrap] == "true" if render_children_for_page?(page, depth) && bootstrap?
dropdow = "dropdown" css += ' dropdown'
link_options = %{class="dropdown-toggle" data-toogle="dropdown"} link_options = %{ class="dropdown-toggle" data-toogle="dropdown"}
href = "#" href = '#'
caret = %{<b class="caret"></b>} caret = %{ <b class="caret"></b>}
end end
output = %{<li id="#{page.slug.to_s.dasherize}-link" class="link#{selected} #{css} #{dropdow}">} output = %{<li id="#{page.slug.to_s.dasherize}-link" class="link#{selected} #{css}">}
output << %{<a href="#{href}" #{link_options}>#{label} #{caret}</a>} output << %{<a href="#{href}"#{link_options}>#{label}#{caret}</a>}
output << render_entry_children(page, depth.succ) if (depth.succ <= @options[:depth].to_i) output << render_entry_children(page, depth.succ) if (depth.succ <= @options[:depth].to_i)
output << %{</li>} output << %{</li>}
@ -120,7 +118,7 @@ module Locomotive
children = page.children_with_minimal_attributes( @options[:add_attributes] ).reject { |c| !include_page?(c) } children = page.children_with_minimal_attributes( @options[:add_attributes] ).reject { |c| !include_page?(c) }
if children.present? if children.present?
output = %{<ul id="#{@options[:id]}-#{page.slug.to_s.dasherize}" class="#{@options[:bootstrap] == "true" ? "dropdown-menu" : ""}">} output = %{<ul id="#{@options[:id]}-#{page.slug.to_s.dasherize}" class="#{bootstrap? ? 'dropdown-menu' : ''}">}
children.each do |c, page| children.each do |c, page|
css = [] css = []
css << 'first' if children.first == c css << 'first' if children.first == c
@ -145,8 +143,13 @@ module Locomotive
end end
end end
::Liquid::Template.register_tag('nav', Nav) def bootstrap?
@options[:bootstrap] == 'true'
end
end end
::Liquid::Template.register_tag('nav', Nav)
end end
end end
end end

View File

@ -49,7 +49,7 @@ describe Locomotive::Liquid::Tags::Nav do
output.should match /<ul id="nav">/ output.should match /<ul id="nav">/
output.should match /<li id="child-1-link" class="link first">/ output.should match /<li id="child-1-link" class="link first">/
output.should match /<\/a><ul id="nav-child-2">/ output.should match /<\/a><ul id="nav-child-2" class="">/
output.should match /<li id="sub-child-1-link" class="link first">/ output.should match /<li id="sub-child-1-link" class="link first">/
output.should match /<li id="sub-child-2-link" class="link last">/ output.should match /<li id="sub-child-2-link" class="link last">/
output.should match /<\/a><\/li><\/ul><\/li><\/ul>/ output.should match /<\/a><\/li><\/ul><\/li><\/ul>/