Add strict_variables/strict_filters render options to check for undefined variables and filters

This commit is contained in:
Ivan Kuznetsov
2016-02-03 10:49:33 +07:00
parent 08de6ed2c5
commit dadd9b4dd2
10 changed files with 139 additions and 12 deletions
+4 -2
View File
@@ -55,9 +55,11 @@ module Liquid
object = object.send(key).to_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
# keywords either. The only thing we got left is to return nil or
# raise an exception if `strict_variables` option is set to true
else
return nil
return nil unless context.strict_variables
raise Liquid::UndefinedVariable, "undefined variable #{key}"
end
# If we are dealing with a drop here we have to