class Haml::Helpers::ErrorReturn

when it shouldn’t be.
It’s used to raise an error when the return value of a helper is used
An object that raises an error when {#to_s} is called.

def initialize(method)

Parameters:
  • message (String) -- The error message to raise when \{#to\_s} is called
def initialize(method)
  @message = <<MESSAGE
od} outputs directly to the Haml template.
ard its return value and use the - operator,
 capture_haml to get the value as a String.
E
end

def inspect

Returns:
  • (String) - A human-readable string representation
def inspect
  "Haml::Helpers::ErrorReturn(#{@message.inspect})"
end

def to_s

Raises:
  • (Haml::Error) - The error
def to_s
  raise Haml::Error.new(@message)
rescue Haml::Error => e
  e.backtrace.shift
  # If the ErrorReturn is used directly in the template,
  # we don't want Haml's stuff to get into the backtrace,
  # so we get rid of the format_script line.
  #
  # We also have to subtract one from the Haml line number
  # since the value is passed to format_script the line after
  # it's actually used.
  if e.backtrace.first =~ /^\(eval\):\d+:in `format_script/
    e.backtrace.shift
    e.backtrace.first.gsub!(/^\(haml\):(\d+)/) {|s| "(haml):#{$1.to_i - 1}"}
  end
  raise e
end