Class: JekyllThemeGuidesMbland::PopLastUrlComponent

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-theme-guides-mbland/tags.rb

Constant Summary collapse

NAME =
'jekyll_theme_guides_mbland_pop_last_url_component'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_tag_name, markup, _tokens) ⇒ PopLastUrlComponent

Returns a new instance of PopLastUrlComponent.



40
41
42
# File 'lib/jekyll-theme-guides-mbland/tags.rb', line 40

def initialize(_tag_name, markup, _tokens)
  @reference = markup.strip
end

Instance Attribute Details

#referenceObject (readonly)

Returns the value of attribute reference.



38
39
40
# File 'lib/jekyll-theme-guides-mbland/tags.rb', line 38

def reference
  @reference
end

Instance Method Details

#render(context) ⇒ Object



44
45
46
47
48
49
# File 'lib/jekyll-theme-guides-mbland/tags.rb', line 44

def render(context)
  scope = context.scopes.detect { |s| s.member?(reference) }
  parent_url = scope[reference]
  result = File.dirname(parent_url)
  result == '/' ? result : "#{result}/"
end