Skip to content

Commit

Permalink
Automatically convert tabbed indentation to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
wildlyinaccurate committed Jan 25, 2021
1 parent 2f7c012 commit 6cc3a08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions features/responsive-image-block.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ Feature: Jekyll responsive_image_block tag
When I run Jekyll
Then I should see "<img alt=\"Lorem ipsum\" src=\"/assets/everybody-loves-jalapeño-pineapple-cornbread.png\" title=\"Magic rainbow adventure!\"" in "_site/index.html"

Scenario: Tabs for indentation
Given I have a responsive_image configuration with "template" set to "_includes/responsive-image.html"
And I have a file "index.html" with:
"""
{% assign path = 'assets/everybody-loves-jalapeño-pineapple-cornbread.png' %}
{% responsive_image_block %}
path: {{ path }}
title: Magic rainbow adventure!
alt: Lorem ipsum
{% endresponsive_image_block %}
"""
When I run Jekyll
Then I should see "<img alt=\"Lorem ipsum\" src=\"/assets/everybody-loves-jalapeño-pineapple-cornbread.png\" title=\"Magic rainbow adventure!\"" in "_site/index.html"

Scenario: Global variables available in templates
Given I have a file "index.html" with:
"""
Expand Down
8 changes: 7 additions & 1 deletion lib/jekyll-responsive-image/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ class Block < Liquid::Block
include Jekyll::ResponsiveImage::Utils

def render(context)
attributes = YAML.load(super)
content = super

if content.include?("\t")
content = content.lines.map {|line| line.gsub(/\G[\t ]/, " ")}.join("\n")
end

attributes = YAML.load(content)
Renderer.new(context.registers[:site], attributes).render_responsive_image
end
end
Expand Down

0 comments on commit 6cc3a08

Please sign in to comment.