Class: Jekyll::Amazon::AmazonTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-amazon/amazon_tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ AmazonTag

Returns a new instance of AmazonTag.



136
137
138
139
140
# File 'lib/jekyll-amazon/amazon_tag.rb', line 136

def initialize(tag_name, markup, tokens)
  super
  parse_options(markup)
  error "No ASIN given in #{tag_name} tag" if asin.nil? || asin.empty?
end

Instance Attribute Details

#asinObject

Returns the value of attribute asin.



133
134
135
# File 'lib/jekyll-amazon/amazon_tag.rb', line 133

def asin
  @asin
end

#template_typeObject

Returns the value of attribute template_type.



134
135
136
# File 'lib/jekyll-amazon/amazon_tag.rb', line 134

def template_type
  @template_type
end

Instance Method Details

#render(context) ⇒ Object



142
143
144
145
146
147
148
# File 'lib/jekyll-amazon/amazon_tag.rb', line 142

def render(context)
  type = template_type || :detail
  AmazonResultCache.instance.setup(context)
  item = AmazonResultCache.instance.item_lookup(asin.to_s)
  return unless item
  send(type, item)
end