module Locomotive
module Liquid
module Tags
# Display the children pages of the site, current page or the parent page. If not precised, nav is applied on the current page.
# The html output is based on the ul/li tags.
#
# Passing through depth will control how many nested children are output
#
# Usage:
#
# {% nav site %} =>
}
output.strip
end
def render_children_for_page?(page, depth)
depth.succ <= @options[:depth].to_i && page.children.reject { |c| !include_page?(c) }.any?
end
# Recursively creates a nested unordered list for the depth specified
def render_entry_children(page, depth)
output = %{}
children = page.children_with_minimal_attributes(@options[:add_attributes]).reject { |c| !include_page?(c) }
if children.present?
output = %{
}
children.each do |c, page|
css = []
css << 'first' if children.first == c
css << 'last' if children.last == c
output << render_entry_link(c, css.join(' '), depth)
end
output << %{
}
end
output
end
# Determines whether or not a page should be a part of the menu
def include_page?(page)
if !page.listed? || page.templatized? || !page.published?
false
elsif @options[:exclude]
(page.fullpath =~ @options[:exclude]).nil?
else
true
end
end
def bootstrap?
@options[:bootstrap] == 'true'
end
end
::Liquid::Template.register_tag('nav', Nav)
end
end
end