Automatically convert tabbed indentation to spaces

This commit is contained in:
Joseph Wynn 2020-04-06 21:57:43 +12:00
parent 2f7c0124eb
commit 6cc3a082a1
No known key found for this signature in database
GPG Key ID: 26540D10C685374E
2 changed files with 21 additions and 1 deletions

View File

@ -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:
"""

View File

@ -4,7 +4,13 @@ module Jekyll
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