Module: Maglev::TagHelper

Included in:
BlockComponent, SectionComponent
Defined in:
app/components/maglev/tag_helper.rb

Defined Under Namespace

Classes: WrapperTagBuilder

Instance Method Summary collapse

Instance Method Details

#setting_tag(setting_id, options = {}, &block) ⇒ Object



18
19
20
21
# File 'app/components/maglev/tag_helper.rb', line 18

def setting_tag(setting_id, options = {}, &block)
  # setting = settings.public_send(setting_id)
  find_setting(settings, setting_id).tag(view_context, options, &block)
end

#wrapper_tag(options = nil, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/components/maglev/tag_helper.rb', line 5

def wrapper_tag(options = nil, &block)
  return WrapperTagBuilder.new(view_context, self) if options.nil?

  tag_options = (options || {}).merge(id: dom_id)
  tag_options[:data] = (tag_options[:data] || {}).merge(tag_data)
  content = view_context.capture(&block)
  view_context.tag.public_send(
    tag_options.delete(:html_tag) || :div,
    content,
    **tag_options
  )
end