module Middleman::AmazonLink::Helpers
Public Instance Methods
amazon(asin, type_or_string = :detail) { |hash| ... }
click to toggle source
# File lib/middleman-amazon-link/helpers.rb, line 18 def amazon(asin, type_or_string = :detail) amazon_opts = amazon_link_settings ecs_opt = { associate_tag: amazon_opts.associate_tag, AWS_access_key_id: amazon_opts.aws_access_key_id, AWS_secret_key: amazon_opts.aws_secret_key, country: amazon_opts.country, } opt = { use_cache: amazon_opts.use_cache, cache_dir: amazon_opts.cache_dir } #binding.pry amazon_lookup = Middleman::AmazonLink::EcsLookupWrapper.new(ecs_opt, opt) hash = amazon_lookup.item_lookup(asin) || {} if block_given? yield(hash) else template = (type_or_string.class == Symbol) ? @@templates[type_or_string] : type_or_string #or raise "no such template type: '#{type}'" template % hash end end