Sha256: f3d1393cec5470de78c1b92646d073052a8065a267def413f74a5d7c72b84538

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

class FormView < Garterbelt::View
  requires :method => :get
  
  def initialize(options, &block)
    super
    self.method = method.to_s.downcase
  end
  
  def content
    form form_options do
      if legal_method != method
        input :type => 'hidden', :name => "_method", :value => method
      end  
        
      block.call if block
    end
  end
  
  def form_options
    initialization_options.merge(:method => legal_method)
  end
  
  def legal_method
    if ['get', 'post'].include?( method )
      method
    else
      'post'
    end 
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
garterbelt-0.1.1 spec/integration/templates/form.rb
garterbelt-0.1.0 spec/integration/templates/form.rb