Class: Trestle::Form::Renderer
- Inherits:
-
Object
- Object
- Trestle::Form::Renderer
- Includes:
- ActionView::Context, ActionView::Helpers::CaptureHelper, Hook::Helpers
- Defined in:
- lib/trestle/form/renderer.rb
Constant Summary collapse
- WHITELISTED_HELPERS =
Whitelisted helpers will concatenate their result to the output buffer when called.
[:row, :col, :render, :tab, :table, :divider, :h1, :h2, :h3, :h4, :h5, :h6, :card, :panel, :well, :turbo_frame_tag]
- RAW_BLOCK_HELPERS =
Raw block helpers will pass their block argument directly to the method without wrapping it in a new output buffer.
[:table, :toolbar]
Class Method Summary collapse
Instance Method Summary collapse
- #fields_for(*args, &block) ⇒ Object
-
#initialize(template, form = nil) ⇒ Renderer
constructor
A new instance of Renderer.
- #render_form(*args, &block) ⇒ Object
- #respond_to_missing?(name, include_all = false) ⇒ Boolean
Methods included from Hook::Helpers
Constructor Details
#initialize(template, form = nil) ⇒ Renderer
Returns a new instance of Renderer.
31 32 33 34 |
# File 'lib/trestle/form/renderer.rb', line 31 def initialize(template, form=nil) @template = template @form = form || @template.form end |
Class Method Details
.ruby2_keywords ⇒ Object
7 8 |
# File 'lib/trestle/form/renderer.rb', line 7 def self.ruby2_keywords(*) end |
Instance Method Details
#fields_for(*args, &block) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/trestle/form/renderer.rb', line 40 def fields_for(*args, &block) result = @form.fields_for(*args) do |f| renderer = self.class.new(@template, f) renderer.render_form(f, &block) end concat(result) end |
#render_form(*args, &block) ⇒ Object
36 37 38 |
# File 'lib/trestle/form/renderer.rb', line 36 def render_form(*args, &block) capture { instance_exec(*args, &block).to_s } end |
#respond_to_missing?(name, include_all = false) ⇒ Boolean
67 68 69 70 71 |
# File 'lib/trestle/form/renderer.rb', line 67 def respond_to_missing?(name, include_all=false) @form.respond_to?(name, include_all) || @template.respond_to?(name, include_all) || super end |