Class: StimulusPlumbers::Form::Fields::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_plumbers/form/fields/renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, theme, field) ⇒ Renderer

Returns a new instance of Renderer.



9
10
11
12
13
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 9

def initialize(template, theme, field)
  @template = template
  @theme    = theme
  @field    = field
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



7
8
9
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 7

def field
  @field
end

#templateObject (readonly)

Returns the value of attribute template.



7
8
9
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 7

def template
  @template
end

#themeObject (readonly)

Returns the value of attribute theme.



7
8
9
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 7

def theme
  @theme
end

Instance Method Details

#call(input_html) ⇒ Object



15
16
17
18
19
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 15

def call(input_html)
  Group.new(template).render(layout: field.layout, error: field.error?) do
    (field_label + input_html.html_safe + field_hint + field_errors).html_safe
  end
end