An object that raises an error when {#to_s} is called. It’s used to raise an error when the return value of a helper is used when it shouldn’t be.
@param message [String] The error message to raise when {#to_s} is called
# File lib/haml/helpers.rb, line 12
12: def initialize(method)
13: @message = #{method} outputs directly to the Haml template.Disregard its return value and use the - operator,or use capture_haml to get the value as a String.
14: end
Any attempt to treat ErrorReturn as a string should cause it to blow up.
@return [String] A human-readable string representation
# File lib/haml/helpers.rb, line 43
43: def inspect
44: "Haml::Helpers::ErrorReturn(#{@message.inspect})"
45: end
Raises an error.
@raise [Haml::Error] The error
# File lib/haml/helpers.rb, line 23
23: def to_s
24: raise Haml::Error.new(@message)
25: rescue Haml::Error => e
26: e.backtrace.shift
27:
28: # If the ErrorReturn is used directly in the template,
29: # we don't want Haml's stuff to get into the backtrace,
30: # so we get rid of the format_script line.
31: #
32: # We also have to subtract one from the Haml line number
33: # since the value is passed to format_script the line after
34: # it's actually used.
35: if e.backtrace.first =~ /^\(eval\):\d+:in `format_script/
36: e.backtrace.shift
37: e.backtrace.first.gsub!(/^\(haml\):(\d+)/) {|s| "(haml):#{$1.to_i - 1}"}
38: end
39: raise e
40: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.