class Forme::Rails::Form

  1. lib/forme/rails.rb
Superclass: Form

Subclass used when using Forme/Rails ERB integration, handling integration with the view template.

Methods

Public Class

  1. new

Public Instance

  1. button
  2. emit
  3. input
  4. inputs
  5. raw_output
  6. tag
  7. template

Attributes

template [R]

The Rails template that created this form.

Public Class methods

new (*)

Set the template object when initializing.

[show source]
# File lib/forme/rails.rb, line 35
def initialize(*)
  super
  @template = @opts[:template]
end

Public Instance methods

button (*)

Return a string version of the button that is already marked as safe.

[show source]
# File lib/forme/rails.rb, line 72
def button(*)
  super.to_s
end
emit (tag)

Serialize and mark as already escaped the string version of the input.

[show source]
# File lib/forme/rails.rb, line 42
def emit(tag)
  template.output_buffer << tag.to_s
end
input (*)

Return a string version of the input that is already marked as safe.

[show source]
# File lib/forme/rails.rb, line 67
def input(*)
  super.to_s
end
inputs (*)

Capture the inputs into a new output buffer, and return the buffer if not given a block

[show source]
# File lib/forme/rails.rb, line 48
def inputs(*)
  if block_given?
    super
  else
    template.send(:with_output_buffer){super}
  end
end
raw_output (s)

Use the template's raw method to mark the given string as html safe.

[show source]
# File lib/forme/rails.rb, line 77
def raw_output(s)
  template.raw(s)
end
tag (type, attr={}, children=[], &block)

If a block is given, create a new output buffer and make sure all the output of the tag goes into that buffer, and return the buffer. Otherwise, just return a string version of the tag that is already marked as safe.

[show source]
# File lib/forme/rails.rb, line 85
def tag(type, attr={}, children=[], &block)
  if block_given?
    template.send(:with_output_buffer){tag_(type, attr, children, &block)}
  else
    _tag(type, attr, children).to_s
  end
end