Giter VIP home page Giter VIP logo

Comments (7)

epage avatar epage commented on September 22, 2024

Its been a while since I've dug into the meaning of this on both sides but I think we were aiming for strict_variables and strict_filters exclusively

From https://github.com/Shopify/liquid

By default, the renderer doesn't raise or in any other way notify you if some variables or filters are missing, i.e. not passed to the render method. You can improve this situation by passing strict_variables: true and/or strict_filters: true options to the render method. When one of these options is set to true, all errors about undefined variables and undefined filters will be stored in errors array of a Liquid::Template instance. Here are some examples:

from liquid-rust.

rydrman avatar rydrman commented on September 22, 2024

I think that's a fair goal for values leaving a filter chain, but it seems like the inconsistent behaviour between the two cases above is surprising. I'm trying to figure out if there's even a way to handle this case in the template, because as far as I can tell there's no way to check if some value is set without getting this error

from liquid-rust.

epage avatar epage commented on September 22, 2024

it seems like the inconsistent behaviour between the two cases above is surprisin

Yes, I had missed the inconsistency in my first read through. Thats something that needs looking into.

I'm trying to figure out if there's even a way to handle this case in the template, because as far as I can tell there's no way to check if some value is set without getting this error

You can do {% if value %} (test) or `{% data contains "value" %} (test).

from liquid-rust.

rydrman avatar rydrman commented on September 22, 2024

Thanks, if you have any inclinations on where I can poke at this issue in the codebase I'd be happy to see if I can resolve the inconsistency

from liquid-rust.

rydrman avatar rydrman commented on September 22, 2024

Any thoughts or follow-up on this one?

from liquid-rust.

epage avatar epage commented on September 22, 2024

The question for any of this is what does Ruby's implementation do with those strict flags set. Any discussion or PR should be focused on that.

from liquid-rust.

rydrman avatar rydrman commented on September 22, 2024

Okay, I've done a repl test against the latest ruby gem and found that filters are not allowed to start with undefined variables when strict_variables is set - which means the former case is incorrect for this implementation, ie {% assign var = value | default: 42 %} does not currently error, but should

from liquid-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.