Class: JekyllThemeGuidesMbland::PopLastUrlComponent
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- JekyllThemeGuidesMbland::PopLastUrlComponent
- 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
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
Instance Method Summary collapse
-
#initialize(_tag_name, markup, _tokens) ⇒ PopLastUrlComponent
constructor
A new instance of PopLastUrlComponent.
- #render(context) ⇒ Object
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
#reference ⇒ Object (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 |