Module: Plutonium::UI::Component::ResolvesTags
- Included in:
- Display::Base::Builder, Form::Base::Builder
- Defined in:
- lib/plutonium/ui/component/resolves_tags.rb
Overview
Turns a resolved as: into a component, for every surface that renders a
field: forms, displays, tables, filter forms and the wizard summary.
as: is a union — a built-in alias (Symbol/String, dispatched to the
builder's #{alias}_tag` method) or a component Class rendered directly (see {Plutonium::Definition::InputAliases}). Every surface has to handle BOTH, so the branch lives here instead of being re-implemented per view — a table or filter form that hand-rolled only the alias half raised NoMethodError: MyPickerComponent_tagon anas:` a form rendered
happily.
A component Class is instantiated with the field builder (the contract
every built-in tag component follows), so as: takes FIELD components; a
component with its own constructor goes through the block form
(input :x do |field| MyComponent.new(value: field.value) end).
Mixed into the form and display field builders, so it is available on
every f a view yields (including the table's display builder).
Instance Method Summary collapse
-
#component_for(tag, **attributes) ⇒ Phlex::SGML
The component to render.
Instance Method Details
#component_for(tag, **attributes) ⇒ Phlex::SGML
Returns the component to render.
33 34 35 36 37 38 |
# File 'lib/plutonium/ui/component/resolves_tags.rb', line 33 def component_for(tag, **attributes, &) tag ||= inferred_field_component return create_component(tag, component_theme_key(tag), **attributes, &) if tag.is_a?(Class) send(:"#{tag}_tag", **attributes, &) end |