Class: ProductImageUrl
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- ProductImageUrl
- Defined in:
- app/liquid/tags/spree_tags.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ ProductImageUrl
constructor
A new instance of ProductImageUrl.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ ProductImageUrl
Returns a new instance of ProductImageUrl.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/liquid/tags/spree_tags.rb', line 49 def initialize(tag_name, markup, tokens) unless markup.empty? if markup =~ /style:([-_a-z0-9]+)/ @style = $1 end if markup =~ /object:([-_a-z0-9]+)/ @object = $1 end end @object ||= 'product' super end |
Instance Method Details
#render(context) ⇒ Object
65 66 67 |
# File 'app/liquid/tags/spree_tags.rb', line 65 def render(context) context[@object].source.images.first..url(@style.to_sym) end |