From 7d529f22d74bacb5d16f2c34153d7b97b993243e Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Tue, 25 Jan 2011 07:48:59 +0800 Subject: [PATCH] I can't believe I missed the include_page? method. Now supports exactly the same standards as the top level list elements, such as unpublished and excluded urls --- lib/locomotive/liquid/tags/nav.rb | 28 ++++++++++++--------- spec/lib/locomotive/liquid/tags/nav_spec.rb | 25 ++++++++++++++++-- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/lib/locomotive/liquid/tags/nav.rb b/lib/locomotive/liquid/tags/nav.rb index 4a31d7ec..7c653af5 100644 --- a/lib/locomotive/liquid/tags/nav.rb +++ b/lib/locomotive/liquid/tags/nav.rb @@ -53,7 +53,8 @@ module Locomotive end private - + + # Determines root node for the list def fetch_entries(context) @current_page = context.registers[:page] @@ -68,16 +69,7 @@ module Locomotive children.delete_if { |p| !include_page?(p) } end - def include_page?(page) - if page.templatized? || !page.published? - false - elsif @options[:exclude] - (page.fullpath =~ @options[:exclude]).nil? - else - true - end - end - + # Returns a list element, a link to the page and its children def render_entry_link(page,css,depth) selected = @current_page.fullpath =~ /^#{page.fullpath}/ ? ' on' : '' @@ -92,10 +84,11 @@ module Locomotive output.strip end + # Recursively creates a nested unordered list for the depth specified def render_entry_children(page,depth) output = %{} - children = page.children_with_minimal_attributes.reject { |c| c.templatized? } + children = page.children_with_minimal_attributes.reject { |c| !include_page?(c) } if children.present? output = %{