Class: VariantsFor

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) ⇒ VariantsFor

Returns a new instance of VariantsFor.



24
25
26
27
28
29
30
31
32
# File 'app/liquid/tags/spree_tags.rb', line 24

def initialize(tag_name, markup, tokens)
  unless markup.empty?
    if markup =~ /([-_a-z0-9]+)/
      @object = $1
    end
  end

  super
end

Instance Method Details

#render(context) ⇒ Object



35
36
37
38
39
# File 'app/liquid/tags/spree_tags.rb', line 35

def render(context)
  return "object with name #{@object} not found" if context[@object].nil?
  @product = context[@object].source
  context.registers[:action_view].render(:partial => 'spree/products/variants')
end