Class: GuidesStyle18F::PopLastUrlComponent
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- GuidesStyle18F::PopLastUrlComponent
- Defined in:
- lib/guides_style_18f/tags.rb
Constant Summary collapse
- NAME =
'guides_style_18f_pop_last_url_component'
Instance Attribute Summary collapse
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
Instance Method Summary collapse
-
#initialize(_tag_name, markup, _) ⇒ PopLastUrlComponent
constructor
A new instance of PopLastUrlComponent.
- #render(context) ⇒ Object
Constructor Details
#initialize(_tag_name, markup, _) ⇒ PopLastUrlComponent
Returns a new instance of PopLastUrlComponent.
29 30 31 |
# File 'lib/guides_style_18f/tags.rb', line 29 def initialize(_tag_name, markup, _) @reference = markup.strip end |
Instance Attribute Details
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
27 28 29 |
# File 'lib/guides_style_18f/tags.rb', line 27 def reference @reference end |
Instance Method Details
#render(context) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/guides_style_18f/tags.rb', line 33 def render(context) scope = context.scopes.detect { |s| s.member?(reference) } parent_url = scope[reference] result = File.dirname(parent_url) result == '/' ? result : "#{result}/" end |