Class: Markaby::Rails::RailsBuilder

Inherits:
Builder
  • Object
show all
Defined in:
lib/markaby/rails/rails_builder.rb

Direct Known Subclasses

Builder

Defined Under Namespace

Classes: FormHelperProxy, OutputBuffer

Constant Summary

Constants inherited from Builder

Builder::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Builder

#output_helpers, #tagset

Instance Method Summary collapse

Methods inherited from Builder

#capture, get, #helper=, ignore_helpers, ignored_helpers, #initialize, #locals=, restore_defaults!, set, #tag!, #text, #to_s

Methods included from BuilderTags

#head, #html_tag, #xhtml_frameset, #xhtml_strict, #xhtml_transitional

Constructor Details

This class inherits a constructor from Markaby::Builder

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Markaby::Builder

Instance Method Details

#form_for(*args, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/markaby/rails/rails_builder.rb', line 4

def form_for(*args, &block)
  @_helper.output_buffer = OutputBuffer.new

  @template.form_for(*args) do |__form_for_variable|
    # flush <form tags> + switch back to markaby
    text(@_helper.output_buffer)
    @_helper.output_buffer = self

    yield FormHelperProxy.new(@_helper, __form_for_variable)

    # switch back to output string output buffer and flush
    # final </form> tag
    @_helper.output_buffer = OutputBuffer.new
  end
  text(@_helper.output_buffer)

  # finally, switch back to our regular buffer
  @_helper.output_buffer = self
end