Make liquid error rendering optional.

Although the author of the liquid template wants to see these errors, they
probably don't want the visitor to see the liquid errors.  Probably the
best fallback when rendering the page for visitors is to render the empty
string for tags with errors.
This commit is contained in:
Dylan Thacker-Smith
2015-05-25 11:24:53 -04:00
parent 070639daba
commit 36200ff704
3 changed files with 13 additions and 3 deletions
+3 -2
View File
@@ -13,7 +13,7 @@ module Liquid
# context['bob'] #=> nil class Context
class Context
attr_reader :scopes, :errors, :registers, :environments, :resource_limits
attr_accessor :exception_handler
attr_accessor :exception_handler, :render_errors
def initialize(environments = {}, outer_scope = {}, registers = {}, rethrow_errors = false, resource_limits = nil)
@environments = [environments].flatten
@@ -22,6 +22,7 @@ module Liquid
@errors = []
@resource_limits = resource_limits || ResourceLimits.new(Template.default_resource_limits)
squash_instance_assigns_with_environments
@render_errors = true
@this_stack_used = false
@@ -69,7 +70,7 @@ module Liquid
errors.push(e)
raise if exception_handler && exception_handler.call(e)
Liquid::Error.render(e)
render_errors ? Liquid::Error.render(e) : ''
end
def invoke(method, *args)