Class: ProductImageUrl

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
app/liquid/tags/spree_tags.rb

Instance Method Summary collapse

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.attachment.url(@style.to_sym)
end