lib/liquid/template.rb in liquid-4.0.0.rc1 vs lib/liquid/template.rb in liquid-4.0.0.rc2
- old
+ new
@@ -18,11 +18,11 @@
@@file_system = BlankFileSystem.new
class TagRegistry
def initialize
- @tags = {}
+ @tags = {}
@cache = {}
end
def [](tag_name)
return nil unless @tags.key?(tag_name)
@@ -78,15 +78,15 @@
def tags
@tags ||= TagRegistry.new
end
def error_mode
- @error_mode || :lax
+ @error_mode ||= :lax
end
def taint_mode
- @taint_mode || :lax
+ @taint_mode ||= :lax
end
# Pass a module with filter methods which should be available
# to all liquid views. Good for registering the standard library
def register_filter(mod)
@@ -105,10 +105,11 @@
template.parse(source, options)
end
end
def initialize
+ @rethrow_errors = false
@resource_limits = ResourceLimits.new(self.class.default_resource_limits)
end
# Parse source code.
# Returns self for easy chaining
@@ -179,16 +180,11 @@
when Hash
options = args.pop
registers.merge!(options[:registers]) if options[:registers].is_a?(Hash)
- context.add_filters(options[:filters]) if options[:filters]
-
- context.global_filter = options[:global_filter] if options[:global_filter]
-
- context.exception_handler = options[:exception_handler] if options[:exception_handler]
-
+ apply_options_to_context(context, options)
when Module, Array
context.add_filters(args.pop)
end
# Retrying a render resets resource usage
@@ -232,8 +228,16 @@
@profiler.stop
end
else
yield
end
+ end
+
+ def apply_options_to_context(context, options)
+ context.add_filters(options[:filters]) if options[:filters]
+ context.global_filter = options[:global_filter] if options[:global_filter]
+ context.exception_handler = options[:exception_handler] if options[:exception_handler]
+ context.strict_variables = options[:strict_variables] if options[:strict_variables]
+ context.strict_filters = options[:strict_filters] if options[:strict_filters]
end
end
end