Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

responsive_image_block error #70

Closed
alter-kaker opened this issue Apr 30, 2018 · 8 comments
Closed

responsive_image_block error #70

alter-kaker opened this issue Apr 30, 2018 · 8 comments
Labels

Comments

@alter-kaker
Copy link

Hi!

I am getting the following error when using responsive_image_block:
~/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/psych.rb:377:in `parse': (<unknown>): mapping values are not allowed in this context

This is my code:

{%- capture path -%} assets/images/_sources/{{ page.featured-image.path | default: site.featured-
image.path }} {%- endcapture -%}
{%- capture alt -%} {{ page.image.alt | default: site.featured-image.path }} {%- endcapture -%}
{% responsive_image_block -%}
  path: {{ path }}
  alt: {{ alt }}
{%- endresponsive_image_block -%}

The responsive_image tag works, but I need to use Liquid variables.
Thank you.

@alter-kaker
Copy link
Author

It turns out that the tag works with no leading whitespace at all inside the block. Perhaps this can be made clearer in the documentation?

@wildlyinaccurate
Copy link
Owner

It should work fine with whitespace, so long as the indentation is consistent (this is mentioned in the docs). There are even tests to make sure this works, although none of the tests use whitespace control like you are in that code ({%- ... -%}).

Was the indentation within that block using tabs or spaces?

@alter-kaker
Copy link
Author

The indentation was using spaces.

@stale
Copy link

stale bot commented Jun 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 6, 2019
@grauschnabel
Copy link

Hi there, I have the same issue, but how to I fix that?

@stale stale bot removed the stale label Jun 8, 2019
@grauschnabel
Copy link

my problem was different. surrounding {{ path }} and {{ alt }} with '' worked fine. Maybe a sentence will be handled like a list of strings instead of a string?

@wildlyinaccurate
Copy link
Owner

@grauschnabel the responsive_image_block contents are parsed as YAML, which supports unquoted strings as well as quoted strings:

unquoted: I am an unquoted string
single_quotes: 'This works too'
double_quotes: "And this"

If you don't know the contents of the string beforehand, it's probably better to use quotes just to be safe. It might even be best to escape the contents, e.g.

title: "{{ title | escape }}"

@stale
Copy link

stale bot commented Jun 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 28, 2019
@stale stale bot closed this as completed Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants