<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,7 +25,7 @@ Mack::ControllerHelpers.constants.each do |cont|
 end
 
 # Find view level Helpers and include them into the Mack::Rendering::ViewTemplate
-# Mack::ViewHelpers.constants.each do |cont|
-#   h = &quot;Mack::ViewHelpers::#{cont}&quot;.constantize
-#   h.include_safely_into(Mack::Rendering::ViewTemplate)
-# end
\ No newline at end of file
+Mack::ViewHelpers.constants.each do |cont|
+  h = &quot;Mack::ViewHelpers::#{cont}&quot;.constantize
+  Mack::Rendering::ViewTemplate.send(:include, h)
+end
\ No newline at end of file</diff>
      <filename>lib/mack/initialization/helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,6 @@ module Mack
     # This class is used to do all the view level bindings.
     # It allows for seperation between the Mack::Controller and the view levels.
     class ViewTemplate
-      include Mack::ViewHelpers
       
       # Allows access to any options passed into the template.
       attr_accessor :options</diff>
      <filename>lib/mack/rendering/view_template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -77,7 +77,37 @@ module Mack
       end
 
       def select(name, *args)
+        var = instance_variable_get(&quot;@#{name}&quot;)
+        fe = FormElement.new(*args)
+        options = {:name =&gt; name, :id =&gt; name}
+        unless fe.calling_method == :to_s
+          options.merge!(:name =&gt; &quot;#{name}[#{fe.calling_method}]&quot;, :id =&gt; &quot;#{name}_#{fe.calling_method}&quot;)
+        end
+
+        content = &quot;&quot;
 
+        opts = fe.options[:options]
+        unless opts.nil?
+          sopts = opts
+          if opts.is_a?(Array)
+          elsif opts.is_a?(Hash)
+            sopts = []
+            opts.sort.each do |k,v|
+              sopts &lt;&lt; [k, v]
+            end
+          else
+            raise ArgumentError.new(&quot;:options must be either an Array of Arrays or a Hash!&quot;)
+          end
+          sel_value = var.send(fe.calling_method) if var
+          sel_value = fe.options[:selected] if fe.options[:selected]
+          sopts.each do |kv|
+            content &lt;&lt; %{&lt;option value=&quot;#{kv[1]}&quot; #{kv[1].to_s == sel_value.to_s ? &quot;selected&quot; : &quot;&quot;}&gt;#{kv[0]}&lt;/option&gt;}
+          end
+          fe.options.delete(:selected)
+          fe.options.delete(:options)
+        end
+        
+        return content_tag(:select, options.merge(fe.options), content)
       end
 
       def text_area(name, *args)</diff>
      <filename>lib/mack/view_helpers/form_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,6 +18,7 @@ describe Mack::ViewHelpers::FormHelpers do
     @cop.bio_file = &quot;~/bio.doc&quot;
     @simple = &quot;hi&quot;
     @default_file = &quot;~/resume.doc&quot;
+    @select_options = [[&quot;one&quot;, 1], [&quot;two&quot;, 2], [&quot;three&quot;, 3]]
   end
   
   describe &quot;check_box&quot; do
@@ -175,6 +176,30 @@ describe Mack::ViewHelpers::FormHelpers do
   
   describe &quot;select&quot; do
     
+    it &quot;should create a nested select tag for a model&quot; do
+      select(:cop, :level).should == %{&lt;select id=&quot;cop_level&quot; name=&quot;cop[level]&quot;&gt;&lt;/select&gt;}
+    end
+    
+    it &quot;should create a non-nested select tag for a simple model&quot; do
+      select(:simple).should == %{&lt;select id=&quot;simple&quot; name=&quot;simple&quot;&gt;&lt;/select&gt;}
+    end
+    
+    it &quot;should build the options from a given array of arrays&quot; do
+      select(:simple, :options =&gt; @select_options).should == %{&lt;select id=&quot;simple&quot; name=&quot;simple&quot;&gt;&lt;option value=&quot;1&quot; &gt;one&lt;/option&gt;&lt;option value=&quot;2&quot; &gt;two&lt;/option&gt;&lt;option value=&quot;3&quot; &gt;three&lt;/option&gt;&lt;/select&gt;}
+    end
+    
+    it &quot;should build the options from a given hash&quot; do
+      select(:simple, :options =&gt; {&quot;one&quot; =&gt; 1, &quot;two&quot; =&gt; 2, &quot;three&quot; =&gt; 3}).should == %{&lt;select id=&quot;simple&quot; name=&quot;simple&quot;&gt;&lt;option value=&quot;1&quot; &gt;one&lt;/option&gt;&lt;option value=&quot;3&quot; &gt;three&lt;/option&gt;&lt;option value=&quot;2&quot; &gt;two&lt;/option&gt;&lt;/select&gt;}
+    end
+    
+    it &quot;should mark an option as selected if the model has it seleceted&quot; do
+      select(:cop, :level, :options =&gt; @select_options).should == %{&lt;select id=&quot;cop_level&quot; name=&quot;cop[level]&quot;&gt;&lt;option value=&quot;1&quot; selected&gt;one&lt;/option&gt;&lt;option value=&quot;2&quot; &gt;two&lt;/option&gt;&lt;option value=&quot;3&quot; &gt;three&lt;/option&gt;&lt;/select&gt;}
+    end
+    
+    it &quot;should mark an option as selected if the selected options is available&quot; do
+      select(:simple, :options =&gt; @select_options, :selected =&gt; 1).should == %{&lt;select id=&quot;simple&quot; name=&quot;simple&quot;&gt;&lt;option value=&quot;1&quot; selected&gt;one&lt;/option&gt;&lt;option value=&quot;2&quot; &gt;two&lt;/option&gt;&lt;option value=&quot;3&quot; &gt;three&lt;/option&gt;&lt;/select&gt;}
+    end
+    
   end
   
   describe &quot;text_area&quot; do</diff>
      <filename>test/unit/view_helpers/form_helpers_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>25aed1978f46fb7a93ba6695563aa9ae4103c20d</id>
    </parent>
  </parents>
  <author>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </author>
  <url>http://github.com/markbates/mack/commit/620bd22da9f75b782db693879b8b654bb4587ab2</url>
  <id>620bd22da9f75b782db693879b8b654bb4587ab2</id>
  <committed-date>2008-08-14T11:59:41-07:00</committed-date>
  <authored-date>2008-08-14T11:59:41-07:00</authored-date>
  <message>Almost finished adding html form helpers. [#19]</message>
  <tree>56023b70e25fc607f6a627e2b28b6ccf61f76648</tree>
  <committer>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </committer>
</commit>
