Class: StimulusPlumbers::Form::Fields::Renderer
- Inherits:
-
Object
- Object
- StimulusPlumbers::Form::Fields::Renderer
- Defined in:
- lib/stimulus_plumbers/form/fields/renderer.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
- #call(input_html) ⇒ Object
-
#initialize(template, theme, field) ⇒ Renderer
constructor
A new instance of Renderer.
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
#field ⇒ Object (readonly)
Returns the value of attribute field.
7 8 9 |
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 7 def field @field end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 7 def template @template end |
#theme ⇒ Object (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 20 21 |
# File 'lib/stimulus_plumbers/form/fields/renderer.rb', line 15 def call(input_html) field_klass = theme.resolve(:form_group, layout: field.layout, error: field.error?).fetch(:classes, "") template.content_tag(:div, class: field_klass) do label_html + input_html.html_safe + hint_html + errors_html end end |