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

handle nil value for key when strict_variables is on #750

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nijikon
Copy link

@nijikon nijikon commented Apr 25, 2016

Fixes #749

@nijikon nijikon force-pushed the handle_nil_value_with_strict_variables branch from f892b64 to bcfaba5 Compare April 25, 2016 16:16
@@ -189,7 +189,7 @@ def find_variable(key)
if scope.nil?
@environments.each do |e|
variable = lookup_and_evaluate(e, key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict_variables really shouldn't be raising in lookup_and_evaluate or we should be calling something else here, since this won't work properly if @evironments has a length of more than 1.

For example:

template = Liquid::Template.parse("{{ foo }}")
template.assigns["foo"] = "works"
puts template.render!({}).inspect  # => "works"
puts template.render!({}, strict_variables: true).inspect  # raises Liquid::UndefinedVariable

@dylanahsmith
Copy link
Contributor

Please add a regression test for #749 and the issue I pointed out in #750 (comment), so we can try to fix this properly this time.

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

Successfully merging this pull request may close these issues.

None yet

3 participants