Sha256: 90b2b70145d6f91a7f75265ec159995114da7678397ab256e3e3995c7e8bcdc5

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require "rubygems" unless defined?(Gem)
require "bundler/setup"
Bundler.require(:default, "development") # Gemfile from gemspec puts dev dependencies in this group

require "ostruct"

class Item < OpenStruct
  def errors
    @errors ||= Errors.new
  end
end

class Errors < Hash
  def initialize
    super { |h, v| h[v] = [] }
  end
  
  def each
    super do |k|
      k, v = k[0..1]
      v.each { |e| yield(k, e) }
    end
  end
end

class App < Padrino::Application
  register Padrino::Rendering
  register Padrino::Helpers
  register BootstrapForms

  disable :raise_errors
  disable :show_exceptions
  disable :logging

  error do
    e = env["sinatra.error"]
    "Error: #{e}\n" << e.backtrace.join("\n")
  end
  
  before do 
    @item = Item.new(:name => "sshaw")
    @builder = BootstrapForms::FormBuilder.new(self, @item)
  end
  
  get "/slim/:view" do
    slim "slim/#{params[:view]}".to_sym
  end

  get "/haml/:view" do
    haml "haml/#{params[:view]}".to_sym
  end
  
  get "/erb/:view" do
    erb "erb/#{params[:view]}".to_sym
  end
end

Padrino.load!
Padrino.mount("App").to('/')

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
padrino_bootstrap_forms-0.1.2 spec/app/app.rb
padrino_bootstrap_forms-0.1.1 spec/app/app.rb
padrino_bootstrap_forms-0.1.0 spec/app/app.rb
padrino_bootstrap_forms-0.0.2 spec/app/app.rb