From 2ac74c9a50b0ab95e539e9ec8316b420604eaf61 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Fri, 25 May 2012 13:24:10 +0200 Subject: [PATCH] fix issue #411 --- lib/locomotive/liquid/tags/nav.rb | 14 +++++++------- spec/lib/locomotive/liquid/tags/nav_spec.rb | 8 +++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/locomotive/liquid/tags/nav.rb b/lib/locomotive/liquid/tags/nav.rb index f327e19d..5b8aef8a 100644 --- a/lib/locomotive/liquid/tags/nav.rb +++ b/lib/locomotive/liquid/tags/nav.rb @@ -28,7 +28,7 @@ module Locomotive if @options[:snippet] template = @options[:snippet].include?('{') ? @options[:snippet] : context[:site].snippets.where(:slug => @options[:snippet] ).try(:first).try(:template) unless template.blank? - @options[:liquid_render] = ::Liquid::Template.parse( template ) + @options[:liquid_render] = ::Liquid::Template.parse(template) @options[:add_attributes] = ['editable_elements'] end end @@ -70,12 +70,12 @@ module Locomotive @site, @page = context.registers[:site], context.registers[:page] children = (case @source - when 'site' then @site.pages.root.minimal_attributes( @options[:add_attributes] ).first # start from home page + when 'site' then @site.pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page when 'parent' then @page.parent || @page when 'page' then @page else - @site.pages.fullpath(@source).minimal_attributes( @options[:add_attributes] ).first - end).children_with_minimal_attributes( @options[:add_attributes] ).to_a + @site.pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first + end).children_with_minimal_attributes(@options[:add_attributes]).to_a children.delete_if { |p| !include_page?(p) } end @@ -86,12 +86,12 @@ module Locomotive icon = @options[:icon] ? '' : '' - title = @options[:liquid_render] ? @options[:liquid_render].render( 'page' => page ) : page.title + title = @options[:liquid_render] ? @options[:liquid_render].render('page' => page) : page.title label = %{#{icon if @options[:icon] != 'after' }#{title}#{icon if @options[:icon] == 'after' }} link_options = caret = '' - href = "/#{page.fullpath}" + href = File.join('/', @site.localized_page_fullpath(page)) if render_children_for_page?(page, depth) && bootstrap? css += ' dropdown' @@ -116,7 +116,7 @@ module Locomotive def render_entry_children(page, depth) output = %{} - 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? output = %{