Add error messages for missing variables when :strict

This commit is contained in:
Daniel Gaiottino
2014-05-06 16:12:46 +02:00
parent 6a1c3cff1a
commit 2bac6267f9
3 changed files with 25 additions and 0 deletions

View File

@@ -203,6 +203,7 @@ module Liquid
end
scope ||= @environments.last || @scopes.last
handle_not_found(key) unless scope.has_key?(key)
variable ||= lookup_and_evaluate(scope, key)
variable = variable.to_liquid
@@ -252,6 +253,7 @@ module Liquid
# No key was present with the desired value and it wasn't one of the directly supported
# keywords either. The only thing we got left is to return nil
else
handle_not_found(markup)
return nil
end
@@ -281,6 +283,10 @@ module Liquid
end
end
end # squash_instance_assigns_with_environments
def handle_not_found(variable)
@errors << "Variable {{#{variable}}} not found" if Template.error_mode == :strict
end
end # Context
end # Liquid