class GuidesStyleMbland::ShouldExpandNavTag

Constants

NAME

Attributes

parent_reference[R]
url_reference[R]

Public Class Methods

new(_tag_name, markup, _) click to toggle source
# File lib/guides_style_mbland/tags.rb, line 11
def initialize(_tag_name, markup, _)
  references = markup.split(',').map(&:strip)
  @parent_reference = references.shift
  @url_reference = references.shift
end

Public Instance Methods

render(context) click to toggle source
# File lib/guides_style_mbland/tags.rb, line 17
def render(context)
  scope = context.scopes.detect { |s| s.member?(url_reference) }
  parent_url = scope[url_reference]
  page_url = context['page']['url']
  page_url == parent_url || page_url.start_with?(parent_url) ||
    expand_nav_default(scope, context)
end

Private Instance Methods

expand_nav_default(scope, context) click to toggle source
# File lib/guides_style_mbland/tags.rb, line 27
def expand_nav_default(scope, context)
  default = scope[parent_reference]['expand_nav']
  default = context['site']['expand_nav'] if default.nil?
  default.nil? ? false : default
end