def errors_on(object, options = { :class => 'errors' }, &block)
      return if object.errors.empty?

      lines = if object.errors.respond_to?(:full_messages)
        object.errors.full_messages
      else
        HamlErrorPresenter.new(object.errors).present(self, &block)
      end

      haml_tag(:div, options) do
        haml_tag(:ul) do
          lines.each do |error|
            haml_tag(:li, error)
          end
        end
      end
    end
def errors_on(object, options = { :class => 'errors' }, &block)
      return if object.errors.empty?

      lines = if object.errors.respond_to?(:full_messages)
        object.errors.full_messages
      else
        HamlErrorPresenter.new(object.errors).present(self, &block)
      end

      haml_tag(:div, options) do
        haml_tag(:ul) do
          lines.each do |error|
            haml_tag(:li, error)
          end
        end
      end
    end
Presents errors on your form. Takes the explicit approach and assumes
 that for every form you have, the copy for the errors are important,
 instead of producing canned responses.

 Allows you to do the following in your haml view:

 @example

   - errors_on @user do |e|
     - e.on [:email, :not_present], "We need your email address."
     - e.on [:password, :not_present], "You must specify a password."

   # produces the following:
   # <div class="errors">
   #   <ul>
   #     <li>We need your email address</li>
   #     <li>You must specify a password.</li>
   #   </ul>
   # </div>

 @param [#errors] object An object responding to #errors. This validation
                  also checks for the presence of a #full_messages method
                  in the errors object for compatibility with ActiveRecord
                  style objects.
 @param [Hash] options a hash of HTML attributes to place on the
               containing div.
 @option options [#to_s] :class (defaults to errors) The css class to put
                                in the div.
 @yield [Sinatra::Helpers::HamlErrorPresenter] an object responding to #on.

 @see Sinatra::Helpers::HamlErrorPresenter#on