wildlyinaccurate / jekyll-responsive-image

An unopinionated Jekyll plugin for generating and using responsive images
MIT License
332 stars 48 forks source link

Render block not working #89

Closed liamtucker closed 4 years ago

liamtucker commented 4 years ago

Getting an issue when I try to use render blocks: {% responsive_image_block %} path: {{ path }} alt: {{ alt }} {% endresponsive_image_block %}

(yaml is formatted correctly with spaces)

It just flags error as found character that cannot start any token while scanning for the next token

everything else seems to work fine

wildlyinaccurate commented 4 years ago

Can you please post the full error output, and the full responsive_image_block code with newlines? Use triple-backticks around it like:

```
{% responsive_image_block %}
  path: {{ path }}
  alt: {{ alt }}
{% endresponsive_image_block %}
```
            
liamtucker commented 4 years ago

Here is the code

{% responsive_image_block %}
  path: {{ include.img }}
  alt: {{ include.title }}
{% endresponsive_image_block %}

the main error I get is:

      Regenerating: 1 file(s) changed at 2020-04-02 20:19:52
                    _includes/work-card.html
  Liquid Exception: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 in /_layouts/casestudy.html
             Error: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
             Error: Run jekyll build --trace for more information.

when i run trace I get

Generating...
  Liquid Exception: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 in /_layouts/casestudy.html
Traceback (most recent call last):
        69: from /Users/liam/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `<main>'
        68: from /Users/liam/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `eval'
        67: from /Users/liam/.rvm/gems/ruby-2.5.1/bin/jekyll:23:in `<main>'

        66: from /Users/liam/.rvm/gems/ruby-2.5.1/bin/jekyll:23:in `load'
        65: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/exe/jekyll:15:in `<top (required)>'
        64: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
        63: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
        62: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
        61: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
        60: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
        59: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
        58: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/commands/build.rb:36:in `process'
        57: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/commands/build.rb:65:in `build'
        56: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/command.rb:28:in `process_site'
        55: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:71:in `process'
        54: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:191:in `render'
        53: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:462:in `render_docs'
        52: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:462:in `each_value'
        51: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:463:in `block in render_docs'
        50: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:463:in `each'
        49: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:464:in `block (2 levels) in render_docs'
        48: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/site.rb:479:in `render_regenerated'
        47: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:62:in `run'
        46: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:88:in `render_document'
        45: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:158:in `place_in_layouts'
        44: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:195:in `render_layout'
        43: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:126:in `render_liquid'
        42: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:28:in `render!'
        41: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
        40: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:29:in `block in render!'
        39: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:42:in `measure_bytes'
        38: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:30:in `block (2 levels) in render!'
        37: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
        36: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
        35: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
        34: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
        33: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
        32: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
        31: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/tags/for.rb:79:in `render'
        30: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/tags/for.rb:150:in `render_segment'
        29: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/context.rb:123:in `stack'
        28: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/tags/for.rb:158:in `block in render_segment'
        27: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/tags/for.rb:158:in `each'
        26: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/tags/for.rb:160:in `block (2 levels) in render_segment'
        25: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
        24: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
        23: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/tags/unless.rb:10:in `render'
        22: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/context.rb:123:in `stack'
        21: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/tags/unless.rb:14:in `block in render'
        20: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:91:in `render'
        19: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
        18: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/tags/include.rb:137:in `render'
        17: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/context.rb:123:in `stack'
        16: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/tags/include.rb:140:in `block in render'
        15: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:28:in `render!'
        14: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
        13: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:29:in `block in render!'
        12: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:42:in `measure_bytes'
        11: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:30:in `block (2 levels) in render!'
        10: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
         9: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
         8: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
         7: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
         6: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
         5: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
         4: from /Users/liam/.rvm/gems/ruby-2.5.1/gems/jekyll-responsive-image-1.5.4/lib/jekyll-responsive-image/block.rb:7:in `render'
         3: from /Users/liam/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/psych.rb:263:in `load'
         2: from /Users/liam/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/psych.rb:350:in `parse'
         1: from /Users/liam/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/psych.rb:402:in `parse_stream'
/Users/liam/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/psych.rb:402:in `parse': (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 (Psych::SyntaxError)

It's weird because its referencing a layout file but even when I remove everything in that file it still appears (that's not the file I'm adding the code to).

Here's the markup in that file just in case:

---
layout: default
---
{% assign images = page.images | split: "," %}

<style>
    .container {
        border-color: {{ page.border }};
    }
    .project--{{ page.slug }} {
        {% if page.bg_img %}
            /*background: url('/assets/images/{{ page.bg_img }}') no-repeat top center;*/
            background-size: auto;
        {% endif %}
        background-color: {{ page.color }};
    }
    {% if page.invert %}
        .project-hero .hero-title {
            color: white;
        }
    {% endif %}
</style>

<div class="project project--{{ page.slug }}">

    <div class="inner">
        <div class="grid">
            <div class="project-hero grid__item" data-grid="7" data-grid-sm="12">
                <div class="reveal">
                    <div class="reveal__item">
                        <h1 class="hero-title">{{ page.heading }}</h1>
                        <p class="intro">{{ page.subheading }}</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="project-media">
            <div class="slider">
                <div class="slider slider--desktop" data-flickity='{ "cellAlign": "left", "contain": true, "imagesLoaded": true, "watchCSS": true }'>
                    {% for image in images %}
                        <img class="lazyload" data-src="/assets/images/{{ image }}" style="width:100%;">
                    {% endfor %}
                </div>
            </div>
        </div>

        <div class="project-content">
            <div class="grid">
                <div class="project-rte rte grid__item" data-grid="9" data-grid-sm="12">
                    {{ content }}
                </div>

                {% assign roles = page.role | split: "," %}
                <aside class="grid__item project-aside" data-grid="3" data-grid-sm="12">
                    <p class="small">
                        <b>Our Role:</b>
                        {% for role in roles %}
                            </br> {{ role }}
                        {% endfor %}
                    </p>
                    <p class="small">
                        <b>Client</b></br>
                        {{ page.client }}
                    </p>
                </aside>
            </div>
        </div>
    </div>

</div>

<div class="related-work">
    <div class="inner">
        <h2 class="h3">Related Work —</h2>
        <div class="grid mt-xs">
            {% for work in site.work %}
                {% unless work.slug == page.slug %}
                    <div class="grid__item" data-grid="6" data-grid-sm="12">
                        {% include work-card.html url=work.url title=work.title excerpt=work.excerpt img=work.images %}
                    </div>
                {% endunless %}
            {% endfor %}
        </div>
    </div>
</div>
wildlyinaccurate commented 4 years ago

Are you using tabs for indentation? The upside to the responsive_image_block using YAML is that it was really easy for me to implement. The downside is that YAML is a fickle beast, and one of the things it doesn't like is tabs for indentation.

wildlyinaccurate commented 4 years ago

If you're using tabs for indentation, I've just pushed version 1.5.5 of the gem which should fix the problem. Let me know if you still have issues :)

liamtucker commented 4 years ago

Late reply as didn't see the notification. This is working now. Your help is appreciated!