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.
110 111 112 113 114 115 116 117 118 |
# File 'lib/forme/sinatra.rb', line 110 def form(obj=nil, attr={}, opts={}, &block) if block h = {:output=>@_out_buf, :hidden_tags=>Forme::Sinatra::HIDDEN_TAGS, :env=>env} (obj.is_a?(Hash) ? attr = attr.merge(h) : opts = opts.merge(h)) Form.form(obj, attr, opts, &block) else Form.form(obj, attr, opts) end end |