diff --git a/features/fixtures/_includes/base-url.html b/features/fixtures/_includes/base-url.html new file mode 100644 index 0000000..e3e6485 --- /dev/null +++ b/features/fixtures/_includes/base-url.html @@ -0,0 +1 @@ + diff --git a/features/responsive-image-block.feature b/features/responsive-image-block.feature index 871cddf..22e70cb 100644 --- a/features/responsive-image-block.feature +++ b/features/responsive-image-block.feature @@ -19,6 +19,22 @@ Feature: Jekyll responsive_image_block tag When I run Jekyll Then I should see "\"Lorem" in "_site/index.html" + Scenario: More complex logic in the block tag Given I have a responsive_image configuration with "template" set to "_includes/responsive-image.html" And I have a file "index.html" with: diff --git a/features/responsive-image-tag.feature b/features/responsive-image-tag.feature index ea377d7..2fbb4eb 100644 --- a/features/responsive-image-tag.feature +++ b/features/responsive-image-tag.feature @@ -9,6 +9,17 @@ Feature: Jekyll responsive_image tag When I run Jekyll Then I should see "\"Foobar\"" in "_site/index.html" + Scenario: Adding custom attributes Given I have a responsive_image configuration with "template" set to "_includes/responsive-image.html" And I have a file "index.html" with: diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 80ab0a9..56f4f9e 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -8,6 +8,10 @@ Then /^Jekyll should throw a "(.+)"$/ do |error_class| assert_raise(Object.const_get(error_class)) { run_jekyll } end +Given /^I have a configuration with:$/ do |config| + write_file('_config.yml', config) +end + Given /^I have a responsive_image configuration with:$/ do |config| write_file('_config.yml', "responsive_image:\n#{config}") end diff --git a/lib/jekyll/responsive_image/block.rb b/lib/jekyll/responsive_image/block.rb index 8df1900..65ba9a6 100644 --- a/lib/jekyll/responsive_image/block.rb +++ b/lib/jekyll/responsive_image/block.rb @@ -4,7 +4,8 @@ module Jekyll include Jekyll::ResponsiveImage::Common def render(context) - config = make_config(context.registers[:site]) + site = context.registers[:site] + config = make_config(site) attributes = YAML.load(super) image_template = attributes['template'] || config['template'] @@ -16,7 +17,7 @@ module Jekyll partial = File.read(image_template) template = Liquid::Template.parse(partial) - template.render!(attributes) + template.render!(attributes.merge(site.site_payload)) end end end diff --git a/lib/jekyll/responsive_image/tag.rb b/lib/jekyll/responsive_image/tag.rb index 0a216cf..714dc60 100644 --- a/lib/jekyll/responsive_image/tag.rb +++ b/lib/jekyll/responsive_image/tag.rb @@ -15,7 +15,8 @@ module Jekyll end def render(context) - config = make_config(context.registers[:site]) + site = context.registers[:site] + config = make_config(site) image = ImageProcessor.process(@attributes['path'], config) @attributes['original'] = image[:original] @@ -26,7 +27,7 @@ module Jekyll partial = File.read(image_template) template = Liquid::Template.parse(partial) - template.render!(@attributes) + template.render!(@attributes.merge(site.site_payload)) end end end