fix issue #39

did committed May 10, 2013
commit 6da49c4ec2180502af6442ca48593a438222b233
Showing 4 changed files with 26 additions and 7 deletions
locomotive/wagon/liquid.rb b/lib/locomotive/wagon/liquid.rb +1 -0
@@ @@ -1,4 +1,5 @@
require 'liquid'
+ require 'locomotive/mounter'
require 'locomotive/wagon/liquid/drops/base'
%w{. drops tags filters}.each do |dir|
locomotive/wagon/liquid/tags/nav.rb b/lib/locomotive/wagon/liquid/tags/nav.rb +3 -2
@@ @@ -20,7 +20,7 @@ module Locomotive
def initialize(tag_name, markup, tokens, context)
if markup =~ Syntax
@source = ($1 || 'page').gsub(/"|'/, '')
- @options = { :id => 'nav', :class => '', :active_class => 'on', :bootstrap => false }
+ @options = { id: 'nav', class: '', active_class: 'on', bootstrap: false }
markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/"|'/, '') }
@options[:exclude] = Regexp.new(@options[:exclude]) if @options[:exclude]
@@ @@ -55,7 +55,8 @@ module Locomotive
output = children_output.join("\n")
if @options[:no_wrapper] != 'true'
- output = %{<ul id="#{@options[:id]}" class="#{@options[:class]}">\n#{output}</ul>}
+ list_class = !@options[:class].blank? ? %( class="#{@options[:class]}") : ''
+ output = %{<nav id="#{@options[:id]}"#{list_class}><ul>\n#{output}</ul></nav>}
end
output
spec/fixtures/default/app/views/pages/tags/nav.liquid.haml +6 -0
@@ @@ -0,0 +1,6 @@
+ ---
+ title: Page to test the nav tag
+ listed: false
+ published: false
+ ---
+ {% nav site %}
\ No newline at end of file
spec/integration/server/basic_spec.rb +16 -5
@@ @@ -54,15 +54,26 @@ describe Locomotive::Wagon::Server do
subject { get '/all'; last_response.body }
- it { should match(/<li id="about-us-link" class="link first "><a href="\/about-us" >About Us <\/a><\/li>/)}
+ it { should_not match(/<nav id="nav">/) }
- it { should match(/<li id="music-link" class="link "><a href="\/music" >Music <\/a><\/li>/)}
+ it { should match(/<li id="about-us-link" class="link first "><a href="\/about-us" >About Us <\/a><\/li>/) }
- it { should match(/<li id="store-link" class="link "><a href="\/store" >Store <\/a><\/li>/)}
+ it { should match(/<li id="music-link" class="link "><a href="\/music" >Music <\/a><\/li>/) }
- it { should match(/<li id="contact-link" class="link last "><a href="\/contact" >Contact Us <\/a><\/li>/)}
+ it { should match(/<li id="store-link" class="link "><a href="\/store" >Store <\/a><\/li>/) }
+
+ it { should match(/<li id="contact-link" class="link last "><a href="\/contact" >Contact Us <\/a><\/li>/) }
+
+ it { should_not match(/<li id="events-link" class="link "><a href="\/events" >Events <\/a><\/li>/) }
+
+ describe 'with wrapper' do
+
+ subject { get '/tags/nav'; last_response.body }
+
+ it { should match(/<nav id="nav">/) }
+
+ end
- it { should_not match(/<li id="events-link" class="link "><a href="\/events" >Events <\/a><\/li>/)}
end