Update the documentation for Wrappers API
This commit is contained in:
parent
b2ffbc18a2
commit
23ae6091ee
22
README.md
22
README.md
|
@ -72,8 +72,8 @@ config.wrappers :tag => :div, :class => :input,
|
|||
|
||||
# Form components
|
||||
b.use :label_input
|
||||
b.use :hint, :tag => :span, :class => :hint
|
||||
b.use :error, :tag => :span, :class => :error
|
||||
b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
|
||||
b.use :error, :wrap_with => { :tag => :span, :class => :error }
|
||||
end
|
||||
```
|
||||
|
||||
|
@ -88,9 +88,9 @@ You can create new _Form components_ using the wrappers API as in the following
|
|||
config.wrappers do |b|
|
||||
b.use :placeholder
|
||||
b.use :label_input
|
||||
b.use :tag => :div, :class => 'separator' do |component|
|
||||
component.use :hint, :tag => :span, :class => :hint
|
||||
component.use :error, :tag => :span, :class => :error
|
||||
b.wrapper :tag => :div, :class => 'separator' do |component|
|
||||
component.use :hint, :wrap_with => { :tag => :span, :class => :hint }
|
||||
component.use :error, :wrap_with => { :tag => :span, :class => :error }
|
||||
end
|
||||
end
|
||||
```
|
||||
|
@ -103,9 +103,9 @@ If you want to customize the custom _Form components_ on demand you can give it
|
|||
config.wrappers do |b|
|
||||
b.use :placeholder
|
||||
b.use :label_input
|
||||
b.use :my_wrapper, :tag => :div, :class => 'separator' do |component|
|
||||
component.use :hint, :tag => :span, :class => :hint
|
||||
component.use :error, :tag => :span, :class => :error
|
||||
b.wrapper :my_wrapper, :tag => :div, :class => 'separator' do |component|
|
||||
component.use :hint, :wrap_with => { :tag => :span, :class => :hint }
|
||||
component.use :error, :wrap_with => { :tag => :span, :class => :error }
|
||||
end
|
||||
end
|
||||
```
|
||||
|
@ -155,9 +155,9 @@ default values to `false` or use the `optional` method. Is preferible to use the
|
|||
config.wrappers :placeholder => false do |b|
|
||||
b.use :placeholder
|
||||
b.use :label_input
|
||||
b.use :tag => :div, :class => 'separator' do |component|
|
||||
component.optional :hint, :tag => :span, :class => :hint
|
||||
component.use :error, :tag => :span, :class => :error
|
||||
b.wrapper :tag => :div, :class => 'separator' do |component|
|
||||
component.optional :hint, :wrap_with => { :tag => :span, :class => :hint }
|
||||
component.use :error, :wrap_with => { :tag => :span, :class => :error }
|
||||
end
|
||||
end
|
||||
```
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
module SimpleForm
|
||||
module Wrappers
|
||||
# Provides the builder syntax for components. The builder provides
|
||||
# only one method (called `use`) and it allows the following invocations:
|
||||
# three methods `use`, `optional` and `wrapper` and they allow the following invocations:
|
||||
#
|
||||
# config.wrappers do |b|
|
||||
# # Use a single component
|
||||
# b.use :placeholder
|
||||
# b.use :html5
|
||||
#
|
||||
# # Use the component, but do not automatically lookup. It will only be triggered when
|
||||
# # :placeholder is explicitly set.
|
||||
# b.optional :placeholder
|
||||
#
|
||||
# # Use a component with specific wrapper options
|
||||
# b.use :error, :tag => "span", :class => "error"
|
||||
# b.use :error, :wrap_with => { :tag => "span", :class => "error" }
|
||||
#
|
||||
# # Use a set of components by wrapping them in a tag+class.
|
||||
# b.use :tag => "div", :class => "another" do |ba|
|
||||
# b.wrapper :tag => "div", :class => "another" do |ba|
|
||||
# ba.use :label
|
||||
# ba.use :input
|
||||
# end
|
||||
|
@ -19,7 +23,7 @@ module SimpleForm
|
|||
# # Use a set of components by wrapping them in a tag+class.
|
||||
# # This wrapper is identified by :label_input, which means it can
|
||||
# # be turned off on demand with `f.input :name, :label_input => false`
|
||||
# b.use :label_input, :tag => "div", :class => "another" do |ba|
|
||||
# b.wrapper :label_input, :tag => "div", :class => "another" do |ba|
|
||||
# ba.use :label
|
||||
# ba.use :input
|
||||
# end
|
||||
|
@ -96,4 +100,4 @@ module SimpleForm
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue