Class: Impulse::BaseRenderer
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Impulse::BaseRenderer
- Defined in:
- app/components/impulse/base_renderer.rb
Constant Summary collapse
- SELF_CLOSING_TAGS =
[:area, :base, :br, :col, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :wbr].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag:, **system_args) ⇒ BaseRenderer
constructor
A new instance of BaseRenderer.
Constructor Details
#initialize(tag:, **system_args) ⇒ BaseRenderer
Returns a new instance of BaseRenderer.
5 6 7 8 9 10 |
# File 'app/components/impulse/base_renderer.rb', line 5 def initialize(tag:, **system_args) @tag = tag @system_args = system_args @system_args = @system_args.transform_keys { |key| key.to_s.dasherize } @system_args[:"data-impulse-view-component"] = "" end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/components/impulse/base_renderer.rb', line 12 def call if SELF_CLOSING_TAGS.include?(@tag) tag(@tag, **@system_args) else content_tag(@tag, content, **@system_args) end end |