Class: JekyllThemeGuidesMbland::ShouldExpandNavTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- JekyllThemeGuidesMbland::ShouldExpandNavTag
- Defined in:
- lib/jekyll-theme-guides-mbland/tags.rb
Constant Summary collapse
- NAME =
'jekyll_theme_guides_mbland_should_expand_nav'.freeze
Instance Attribute Summary collapse
-
#parent_reference ⇒ Object
readonly
Returns the value of attribute parent_reference.
-
#url_reference ⇒ Object
readonly
Returns the value of attribute url_reference.
Instance Method Summary collapse
-
#initialize(_tag_name, markup, _tokens) ⇒ ShouldExpandNavTag
constructor
A new instance of ShouldExpandNavTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(_tag_name, markup, _tokens) ⇒ ShouldExpandNavTag
Returns a new instance of ShouldExpandNavTag.
11 12 13 14 15 |
# File 'lib/jekyll-theme-guides-mbland/tags.rb', line 11 def initialize(_tag_name, markup, _tokens) references = markup.split(',').map(&:strip) @parent_reference = references.shift @url_reference = references.shift end |
Instance Attribute Details
#parent_reference ⇒ Object (readonly)
Returns the value of attribute parent_reference.
9 10 11 |
# File 'lib/jekyll-theme-guides-mbland/tags.rb', line 9 def parent_reference @parent_reference end |
#url_reference ⇒ Object (readonly)
Returns the value of attribute url_reference.
9 10 11 |
# File 'lib/jekyll-theme-guides-mbland/tags.rb', line 9 def url_reference @url_reference end |
Instance Method Details
#render(context) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/jekyll-theme-guides-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) || (scope, context) end |