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.
40 41 42 |
# File 'lib/guides_style_18f/tags.rb', line 40 def initialize(_tag_name, markup, _) @reference = markup.strip end |
Instance Attribute Details
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
38 39 40 |
# File 'lib/guides_style_18f/tags.rb', line 38 def reference @reference end |
Instance Method Details
#render(context) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/guides_style_18f/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 |