Class: Ariadne::Form::BaseComponent

Inherits:
BaseComponent
  • Object
show all
Extended by:
Ariadne::Forms::ActsAsComponent
Includes:
ClassNameHelper
Defined in:
app/components/ariadne/form/base_component.rb

Overview

:nodoc:

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ACCEPT_ANYTHING

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Attribute Summary

Attributes included from Ariadne::Forms::ActsAsComponent

#template_root_path

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ariadne::Forms::ActsAsComponent

compile!, extended, renders_templates

Methods included from ClassNameHelper

#merge_class_names

Methods inherited from BaseComponent

#class_for, #component, component_id, #component_id, component_name, #html_attributes, i18n_scope, #in_turbo_frame, #in_turbo_stream, #options, stimulus_name, #styles, translate, #validate_aria_label!

Methods included from ViewHelper

generate_id

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes, #prepend_action, #prepend_controller, #prepend_data_attribute

Methods included from ViewComponent::StyleVariants

#merged_styles

Class Method Details

.inherited(base) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/components/ariadne/form/base_component.rb', line 10

def self.inherited(base)
  base_path = Ariadne::Forms::Utils.const_source_location(base.name)

  unless base_path
    warn("Could not identify the template for #{base}")
    return
  end

  dir = File.dirname(base_path)
  base.renders_template(File.join(dir, "#{base.name.demodulize.underscore}.html.erb"), :render_template)
end

Instance Method Details

#contentObject



31
32
33
34
35
36
37
38
# File 'app/components/ariadne/form/base_component.rb', line 31

def content
  return @__prf_content if defined?(@__prf_content_evaluated) && @__prf_content_evaluated

  @__prf_content_evaluated = true
  @__prf_content = capture do
    @__prf_content_block.call
  end
end

#input?Boolean

:nocov:

Returns:

  • (Boolean)


46
47
48
# File 'app/components/ariadne/form/base_component.rb', line 46

def input?
  false
end

#perform_render(&block) ⇒ Object



24
25
26
27
28
29
# File 'app/components/ariadne/form/base_component.rb', line 24

def perform_render(&block)
  return "" unless render?

  @__prf_content_block = block
  compile_and_render_template
end

#render?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/components/ariadne/form/base_component.rb', line 54

def render?
  true
end

#to_componentObject



50
51
52
# File 'app/components/ariadne/form/base_component.rb', line 50

def to_component
  self
end

#typeObject

:nocov:



41
42
43
# File 'app/components/ariadne/form/base_component.rb', line 41

def type
  :component
end