Module: Forme::Sinatra::ERB
- Defined in:
- lib/forme/sinatra.rb
Overview
Instance Method Summary collapse
-
#form(obj = nil, attr = {}, opts = {}, &block) ⇒ Object
Create a
Form
object and yield it to the block, injecting the opening form tag before yielding and the closing form tag after yielding.
Instance Method Details
#form(obj = nil, attr = {}, opts = {}, &block) ⇒ Object
Create a Form
object and yield it to the block, injecting the opening form tag before yielding and the closing form tag after yielding.
Argument Handling:
- No args
-
Creates a
Form
object with no options and not associated to anobj
, and with no attributes in the opening tag. - 1 hash arg
-
Treated as opening form tag attributes, creating a
Form
object with no options. - 1 non-hash arg
-
Treated as the
Form
‘sobj
, with empty options and no attributes in the opening tag. - 2 hash args
-
First hash is opening attributes, second hash is
Form
options. - 1 non-hash arg, 1-2 hash args
-
First argument is
Form
‘s obj, second is opening attributes, third if provided isForm
’s options.
79 80 81 82 83 |
# File 'lib/forme/sinatra.rb', line 79 def form(obj=nil, attr={}, opts={}, &block) h = {:output=>@_out_buf} (obj.is_a?(Hash) ? attr = attr.merge(h) : opts = opts.merge(h)) Form.form(obj, attr, opts, &block) end |