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

parse_for_liquid_tag errors without line numbers #1734

Open
jg-rp opened this issue Jul 10, 2023 · 2 comments
Open

parse_for_liquid_tag errors without line numbers #1734

jg-rp opened this issue Jul 10, 2023 · 2 comments

Comments

@jg-rp
Copy link
Contributor

jg-rp commented Jul 10, 2023

While adding some nested liquid tag test cases to the golden liquid test suite, I was getting errors like this:

  1) Error:
Golden::liquid.golden.liquid_tag#test_0001_bare liquid tag in liquid tag:
NoMethodError: undefined method `-' for nil:NilClass

            parse_context.line_number -= 1
                                      ^
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/block_body.rb:50:in `parse_for_liquid_tag'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/block_body.rb:111:in `parse_liquid_tag'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/block_body.rb:145:in `parse_for_document'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/block_body.rb:29:in `parse'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/document.rb:55:in `parse_body'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/document.rb:23:in `parse'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/document.rb:7:in `parse'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/template.rb:111:in `parse'
    /home/james/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/liquid-5e92b3a89a11/lib/liquid/template.rb:97:in `parse'
    golden_liquid.rb:25:in `block (5 levels) in <main>'

Adding line_numbers: true to Liquid::Template.parse solved the problem.

This is can be reproduced with the following:

require 'liquid'

template = <<~LIQUID
{%- liquid
    liquid
    echo 'foo'
-%}
LIQUID

Liquid::Template.parse(template).render!()
@john-goncalves-hc
Copy link

I stumbled upon the same issue, any news on this?

@john-goncalves-hc
Copy link

@jg-rp did a quick search on liquid gem's tests for "line_number" and it turns out we have to Liquid::Template.parse(template, line_numbers: true).render!()!

Hope it helps 👋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants