<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/views/simple_form/notifier/custom_template.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -129,6 +129,26 @@ class SimpleForm
         write_inheritable_hash(:form_headers, hash)
       end
 
+      # Customized template for your e-mail, if you don't want to use default
+      # 'contact' template or need more than one contact form with different
+      # template layouts.
+      #
+      # When a symbol is given, it will call a method on the form object with
+      # the same name as the symbol. As a proc, it receives a simple form
+      # instance. Both method and proc must return a string with the template
+      # name. Defaults to 'contact'.
+      #
+      # == Examples
+      #
+      #   class ContactForm &lt; SimpleForm
+      #     # look for a template in views/simple_form/notifier/my_template.erb
+      #     template 'my_template'
+      #   end
+      #
+      def template(new_template)
+        write_inheritable_attribute(:form_template, new_template)
+      end
+
       # Values from request object to be appended to the contact form.
       # Whenever used, you have to send the request object when initializing the object:
       #</diff>
      <filename>lib/simple_form/dsl.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,13 +31,15 @@ class SimpleForm
 
     alias :add   :store
     alias :count :size
+    alias :get   :[]
 
     def on(attribute)
       attribute = attribute.to_sym
-      return nil unless self[attribute]
+      return nil unless get(attribute)
 
-      generate_message_for(attribute, self[attribute])
+      generate_message_for(attribute, get(attribute))
     end
+    alias :[] :on
 
     def full_messages
       map do |attribute, message|</diff>
      <filename>lib/simple_form/errors.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,7 @@ class SimpleForm
       @from       = get_from_class_and_eval(form, :form_sender)
       @subject    = get_from_class_and_eval(form, :form_subject)
       @recipients = get_from_class_and_eval(form, :form_recipients)
+      @template   = get_from_class_and_eval(form, :form_template)
 
       raise ScriptError, &quot;You forgot to setup #{form.class.name} recipients&quot; if @recipients.blank?
       raise ScriptError, &quot;You set :append values but forgot to give me the request object&quot; if form.request.nil? &amp;&amp; !form.class.form_appendable.blank?</diff>
      <filename>lib/simple_form/notifier.rb</filename>
    </modified>
    <modified>
      <diff>@@ -43,6 +43,24 @@ class SimpleFormErrorsTest &lt; ActiveSupport::TestCase
     assert_equal nil,                 form.errors.on(:message)
   end
 
+  def test_array_like_option_acts_as_an_alias_for_on
+    form = ContactForm.new(:email =&gt; 'not_valid')
+    form.valid?
+    assert_equal &quot;can't be blank&quot;,       form.errors[:name]
+    assert_equal form.errors.on(:name),  form.errors[:name]
+    assert_equal &quot;is invalid&quot;,           form.errors[:email]
+    assert_equal form.errors.on(:email), form.errors[:email]
+    assert_equal nil,                    form.errors[:message]
+  end
+
+  def test_get_returns_the_real_value_in_the_given_attribute
+    form = ContactForm.new(:email =&gt; 'not_valid')
+    form.valid?
+    assert_equal :blank,   form.errors.get(:name)
+    assert_equal :invalid, form.errors.get(:email)
+    assert_equal nil,      form.errors.get(:message)
+  end
+
   def test_full_messages
     form = ContactForm.new(:email =&gt; 'not_valid')
     form.valid?</diff>
      <filename>test/errors_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,6 +12,8 @@ class SimpleFormNotifierTest &lt; ActiveSupport::TestCase
     test_file  = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), 'test_file.txt'))
     @with_file = FileForm.new(:name =&gt; 'Jos&#233;', :email =&gt; 'my.email@my.domain.com', :message =&gt; &quot;Cool&quot;, :file =&gt; test_file)
 
+    @template = TemplateForm.new(@valid_attributes)
+
     ActionMailer::Base.deliveries = []
   end
 
@@ -158,6 +160,23 @@ class SimpleFormNotifierTest &lt; ActiveSupport::TestCase
     assert_no_match /File/, ActionMailer::Base.deliveries.first.body
   end
 
+  def test_form_with_customized_template_raise_missing_template_if_not_found
+    assert_raise ActionView::MissingTemplate do
+      @template.deliver
+    end
+  end
+
+  def test_form_with_customized_template_render_correct_template
+    begin
+      default_template_root = SimpleForm::Notifier.template_root
+      SimpleForm::Notifier.template_root = File.join(File.dirname(__FILE__), 'views')
+      @template.deliver
+      assert_match 'Hello from my cystom template!', ActionMailer::Base.deliveries.last.body
+    ensure
+      SimpleForm::Notifier.template_root = default_template_root
+    end
+  end
+
   def teardown
     I18n.reload!
   end</diff>
      <filename>test/notifier_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,10 @@ class NullRecipient &lt; SimpleForm
   sender 'my.email@my.domain.com'
 end
 
+class TemplateForm &lt; ContactForm
+  template 'custom_template'
+end
+
 # Needed to correctly test an uploaded file
 class ActionController::TestUploadedFile
   def read</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d930b347a1c2f4719f1b916fd91d0e0dbed57050</id>
    </parent>
    <parent>
      <id>32883dc92fd7a969655e8a5c33eb529302c8fba4</id>
    </parent>
  </parents>
  <author>
    <name>Jos&#233; Valim</name>
    <email>jose.valim@gmail.com</email>
  </author>
  <url>http://github.com/josevalim/simple_form/commit/65451c8879afdbd2ea281a3c2680744c5f7e6edd</url>
  <id>65451c8879afdbd2ea281a3c2680744c5f7e6edd</id>
  <committed-date>2009-11-09T05:00:14-08:00</committed-date>
  <authored-date>2009-11-09T05:00:14-08:00</authored-date>
  <message>Merge branch 'master' of git@github.com:josevalim/simple_form</message>
  <tree>6c654a76a8c2d026dc44bdb1728e032fe854caf9</tree>
  <committer>
    <name>Jos&#233; Valim</name>
    <email>jose.valim@gmail.com</email>
  </committer>
</commit>
