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
35 def initialize(*)
36   super
37   @template = @opts[:template]
38 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
72 def button(*)
73   super.to_s
74 end
emit (tag)

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

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

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

[show source]
   # File lib/forme/rails.rb
67 def input(*)
68   super.to_s
69 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
48 def inputs(*)
49   if block_given?
50     super
51   else
52     template.send(:with_output_buffer){super}
53   end
54 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
77 def raw_output(s)
78   template.raw(s)
79 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
85 def tag(type, attr={}, children=[], &block)
86   if block_given?
87     template.send(:with_output_buffer){tag_(type, attr, children, &block)}
88   else
89     _tag(type, attr, children).to_s
90   end
91 end