|
@@ -38,7 +38,8 @@ examples how to use
|
|
|
@url_encode = url_encode
|
|
|
end
|
|
|
|
|
|
- def render
|
|
|
+ def render(debug_errors: true)
|
|
|
+ @debug_errors = debug_errors
|
|
|
ERB.new(@template.to_s).result(binding)
|
|
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
|
raise StandardError, e.message if e.is_a? SyntaxError
|
|
@@ -83,16 +84,16 @@ examples how to use
|
|
|
object_name = object_methods.shift
|
|
|
|
|
|
# if no object is given, just return
|
|
|
- return '#{no such object}' if object_name.blank? # rubocop:disable Lint/InterpolationCheck
|
|
|
+ return debug("\#{no such object}") if object_name.blank?
|
|
|
|
|
|
object_refs = @objects[object_name] || @objects[object_name.to_sym]
|
|
|
|
|
|
# if object is not in available objects, just return
|
|
|
- return "\#{#{object_name} / no such object}" if !object_refs
|
|
|
+ return debug("\#{#{object_name} / no such object}") if !object_refs
|
|
|
|
|
|
# if content of method is a complex datatype, just return
|
|
|
if object_methods.blank? && object_refs.class != String && object_refs.class != Float && object_refs.class != Integer
|
|
|
- return "\#{#{key} / no such method}"
|
|
|
+ return debug("\#{#{key} / no such method}")
|
|
|
end
|
|
|
|
|
|
previous_object_refs = ''
|
|
@@ -115,7 +116,7 @@ examples how to use
|
|
|
next if method == 'value'
|
|
|
|
|
|
if object_methods_s == ''
|
|
|
- value = "\#{#{object_name}.#{object_methods_s} / no such method}"
|
|
|
+ value = debug("\#{#{object_name}.#{object_methods_s} / no such method}")
|
|
|
break
|
|
|
end
|
|
|
|
|
@@ -123,7 +124,7 @@ examples how to use
|
|
|
if %r{\A(?<method_id>[^(]+)\((?<parameter>[^)]+)\)\z} =~ method
|
|
|
|
|
|
if parameter != parameter.to_i.to_s
|
|
|
- value = "\#{#{object_name}.#{object_methods_s} / invalid parameter: #{parameter}}"
|
|
|
+ value = debug("\#{#{object_name}.#{object_methods_s} / invalid parameter: #{parameter}}")
|
|
|
break
|
|
|
end
|
|
|
|
|
@@ -131,14 +132,14 @@ examples how to use
|
|
|
arguments = Array(parameter.to_i)
|
|
|
method = method_id
|
|
|
rescue
|
|
|
- value = "\#{#{object_name}.#{object_methods_s} / #{e.message}}"
|
|
|
+ value = debug("\#{#{object_name}.#{object_methods_s} / #{e.message}}")
|
|
|
break
|
|
|
end
|
|
|
end
|
|
|
|
|
|
# if method exists
|
|
|
if !object_refs.respond_to?(method.to_sym)
|
|
|
- value = "\#{#{object_name}.#{object_methods_s} / no such method}"
|
|
|
+ value = debug("\#{#{object_name}.#{object_methods_s} / no such method}")
|
|
|
break
|
|
|
end
|
|
|
begin
|
|
@@ -150,7 +151,7 @@ examples how to use
|
|
|
previous_object_refs.should_clone_inline_attachments = true
|
|
|
end
|
|
|
rescue => e
|
|
|
- value = "\#{#{object_name}.#{object_methods_s} / #{e.message}}"
|
|
|
+ value = debug("\#{#{object_name}.#{object_methods_s} / #{e.message}}")
|
|
|
break
|
|
|
end
|
|
|
end
|
|
@@ -183,6 +184,10 @@ examples how to use
|
|
|
|
|
|
private
|
|
|
|
|
|
+ def debug(message)
|
|
|
+ @debug_errors ? message : '-'
|
|
|
+ end
|
|
|
+
|
|
|
def convert_to_timezone(value)
|
|
|
return Translation.timestamp(@locale, @timezone, value) if value.instance_of?(ActiveSupport::TimeWithZone)
|
|
|
return Translation.date(@locale, value) if value.instance_of?(Date)
|