Skip to content

Commit

Permalink
Add support for original erb templates
Browse files Browse the repository at this point in the history
  • Loading branch information
tokzk committed Jan 13, 2017
1 parent ba6d99b commit 99578ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jekyll-amazon:
# Affiliate account (e.g. `'us'` for United States).
# default: 'us'
# 'br'/'ca'/'cn'/'de'/'es'/'fr'/'in'/'it'/'jp'/'mx/'uk'/'us'
template_dir: '_templates' # original template directory
```


Expand Down
7 changes: 6 additions & 1 deletion lib/jekyll-amazon/amazon_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def setup(context)
@site = context.registers[:site]
@config = @site.config['jekyll-amazon'] || {}
country = @config['country'] || DEFAULT_COUNTRY
@template_dir = @config['template_dir']
AmazonResultCache.instance.setup(country)
end

Expand All @@ -138,7 +139,11 @@ def parse_options(markup)
end

def render_from_file(type, item)
file = File.expand_path("../../templates/#{type}.erb", __dir__)
if @template_dir
template_file = File.expand_path("#{type}.erb", @template_dir)
file = template_file if File.exist? template_file
end
file ||= File.expand_path("../../templates/#{type}.erb", __dir__)
ERB.new(open(file).read).result(binding)
end

Expand Down

0 comments on commit 99578ff

Please sign in to comment.