Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tylerhunt/formulate
base: c6b6ca864d
...
head fork: tylerhunt/formulate
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 11 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 04, 2012
@tylerhunt Don't require the engine by default. 68892f1
@tylerhunt Use the helper to set the default form builder. eed2355
@tylerhunt Document recent changes in README.
Include details on how to use the provided Rails engine and helper.
Mention Haml requirement.
82e71e8
@tylerhunt Course correct for broken assets without engine.
Without a Rails engine in place, the asset detection breaks. This
restores the engine, but without the automatic helper inclusion,
which will no longer be supported.
aa93bf9
Commits on Mar 11, 2013
@tylerhunt Bump version to 0.0.10. 8ebf89b
Commits on Dec 04, 2013
@tylerhunt Clean up Gemfile. ed13eb5
@tylerhunt Require Rails ~> 4.0. fa01e2a
@tylerhunt Add changelog. f3e383f
@tylerhunt Release 0.1.0. 6f799ff
@tylerhunt Clean up Rakefile. cbc8ca4
@tylerhunt Add Rake and Bundler development dependencies. 22e3cf3
View
58 CHANGELOG.md
@@ -0,0 +1,58 @@
+# Changelog
+
+## 0.1.0 (2013-12-03)
+
+ * Require Rails 4 ([Tyler Hunt][tylerhunt])
+
+## 0.0.10 (2013-03-11)
+
+ * Set the default form builder using helper option ([Tyler Hunt][tylerhunt])
+ * Make the form helper opt-in ([Tyler Hunt][tylerhunt])
+ * Overhaul the form styles ([Tyler Hunt][tylerhunt])
+
+## 0.0.9 (2012-10-17)
+
+ * Fix form helper when not using Active Record ([Tyler Hunt][tylerhunt])
+
+## 0.0.8 (2012-10-17)
+
+ * Allow a custom CSS form class to be set ([Tyler Hunt][tylerhunt])
+ * Keep Rails’ original CSS form class intact ([Tyler Hunt][tylerhunt])
+ * Support `placeholder: true` for automatic values ([Tyler Hunt][tylerhunt])
+
+## 0.0.7 (2012-05-19)
+
+ * Disable reset styles ([Tyler Hunt][tylerhunt])
+ * Improve styling of inputs ([Tyler Hunt][tylerhunt])
+ * Ensure `:label` is not used as input option ([Tyler Hunt][tylerhunt])
+
+## 0.0.6 (2012-05-11)
+
+ * Use custom error handler to add class to field ([Tyler Hunt][tylerhunt])
+ * Add `:prefix` and `:suffix` options ([Tyler Hunt][tylerhunt])
+
+## 0.0.5 (2012-05-10)
+
+ * Make the input `font-family` configurable ([Tyler Hunt][tylerhunt])
+ * Switch to pessimistic version constraints ([Tyler Hunt][tylerhunt])
+
+## 0.0.4 (2012-05-01)
+
+ * Yield value and hide input when passing a block ([Tyler Hunt][tylerhunt])
+ * Change `:style` option to `:class` ([Tyler Hunt][tylerhunt])
+ * Fix read-only styles ([Tyler Hunt][tylerhunt])
+
+## 0.0.3 (2012-04-29)
+
+ * Add state select and country select input helpers ([Tyler Hunt][tylerhunt])
+
+## 0.0.2 (2012-04-28)
+
+ * Specify dependencies on Ruby 1.9 and Haml ([Tyler Hunt][tylerhunt])
+ * Fix default form builder setting in initializer ([Tyler Hunt][tylerhunt])
+
+## 0.0.1 (2012-04-28)
+
+ * Initial release ([Tyler Hunt][tylerhunt])
+
+[tylerhunt]: https://github.com/tylerhunt
View
3  Gemfile
@@ -1,4 +1,3 @@
-source 'https://rubygems.org'
+source 'https://rubygems.org/'
-# Specify your gem's dependencies in formulate.gemspec
gemspec
View
22 README.md
@@ -7,6 +7,12 @@ form builder in Rails, and a Sass stylesheet to provide some level of stylistic
normalization.
+## Haml Requirement
+
+Formulate's `FormBuilder` relies on some helper methods provided by Haml, so
+it will only work when used within Haml templates.
+
+
## Installation
Add this line to your application's `Gemfile`:
@@ -26,10 +32,18 @@ Or install it yourself as:
## Usage
-The form builder will be used automatically whenever the `#form_for` helper is
-called, so you don't need to do anything special to start using its methods. It
-also doesn't clobber any of the built-in form builder methods, so your forms
-should continue to work without modification, giving you the ability to
+Formulate provides a helper module to be included in your Rails controllers.
+You can also load the helper in your `ApplicationController` to use it across
+your entire app.
+
+``` ruby
+class ApplicationController < ActionController::Base
+ helper Formulate::FormHelper
+end
+```
+
+Formulate doesn't clobber any of the built-in form builder methods, so your
+forms should continue to work without modification, giving you the ability to
selectively begin using Formulate in your applications where you see fit.
View
3  Rakefile
@@ -1,2 +1 @@
-#!/usr/bin/env rake
-require "bundler/gem_tasks"
+require 'bundler/gem_tasks'
View
35 formulate.gemspec
@@ -1,22 +1,25 @@
require './lib/formulate/version'
-Gem::Specification.new do |gem|
- gem.name = 'formulate'
- gem.version = Formulate::VERSION
- gem.summary = 'Rails form builder with flexible markup and styles.'
- gem.homepage = 'http://github.com/tylerhunt/formulate'
- gem.author = 'Tyler Hunt'
+Gem::Specification.new do |spec|
+ spec.name = 'formulate'
+ spec.version = Formulate::VERSION
+ spec.authors = ['Tyler Hunt']
+ spec.summary = 'Rails form builder with flexible markup and styles.'
+ spec.homepage = 'https://github.com/tylerhunt/formulate'
+ spec.license = 'MIT'
- gem.required_ruby_version = '>= 1.9'
+ spec.required_ruby_version = '>= 1.9'
- gem.add_dependency 'actionpack', '~> 3.0'
- gem.add_dependency 'activesupport', '~> 3.0'
- gem.add_dependency 'carmen', '~> 0.2.0'
- gem.add_dependency 'haml', '~> 3.0'
- gem.add_dependency 'sass-rails', '~> 3.0'
+ spec.add_dependency 'actionpack', '~> 4.0'
+ spec.add_dependency 'activesupport', '~> 4.0'
+ spec.add_dependency 'carmen', '~> 0.2.0'
+ spec.add_dependency 'haml', '~> 4.0'
+ spec.add_dependency 'sass-rails', '~> 4.0'
+ spec.add_development_dependency 'bundler'
+ spec.add_development_dependency 'rake'
- gem.files = `git ls-files`.split($\)
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
- gem.require_paths = ['lib']
+ spec.files = `git ls-files`.split($\)
+ spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
+ spec.require_paths = ['lib']
end
View
7 lib/formulate/engine.rb
@@ -1,11 +1,4 @@
module Formulate
class Engine < ::Rails::Engine
- initializer 'formulate.initialize', before: 'action_view.set_configs' do |app|
- app.config.action_view.default_form_builder = Formulate::FormBuilder
-
- ActiveSupport.on_load(:action_view) do
- include Formulate::FormHelper
- end
- end
end
end
View
2  lib/formulate/form_builder.rb
@@ -96,7 +96,7 @@ def input(method, options={}, &block)
label = label != false ? label(method, label) : nil
markup = [label, prefix, input, suffix].compact
- markup.reverse! if type.in?(:check_box, :radio_button)
+ markup.reverse! if type.in?([:check_box, :radio_button])
markup << @template.capture_haml do
yield(object.send(method)) if block_given?
View
5 lib/formulate/form_helper.rb
@@ -4,12 +4,15 @@ module FormHelper
def form_for(record, options={}, &proc)
options[:html] ||= {}
+ options[:builder] ||= FormBuilder
case record
when String, Symbol
options[:html][:class] ||= ''
else
- apply_form_for_options!(record, options)
+ object = record.is_a?(Array) ? record.last : record
+ raise ArgumentError, 'First argument in form cannot contain nil or be empty' unless object
+ apply_form_for_options!(record, object, options)
end
options[:html][:class] << ' formulate'
View
2  lib/formulate/version.rb
@@ -1,3 +1,3 @@
module Formulate
- VERSION = '0.0.9'
+ VERSION = '0.1.0'
end

No commit comments for this range

Something went wrong with that request. Please try again.