Class: Primer::Forms::BaseComponent
- Inherits:
-
Object
- Object
- Primer::Forms::BaseComponent
- Extended by:
- ActsAsComponent
- Includes:
- ClassNameHelper
- Defined in:
- lib/primer/forms/base_component.rb
Overview
:nodoc:
Direct Known Subclasses
ActionMenu, Button, Caption, CheckBox, CheckBoxGroup, FormControl, FormReference, Group, HiddenField, Multi, PrimerBaseComponentWrapper, RadioButton, RadioButtonGroup, Select, Separator, SpacingWrapper, SubmitButton, TextArea, TextField, ToggleSwitch, ValidationMessage
Instance Attribute Summary
Attributes included from ActsAsComponent
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
-
#input? ⇒ Boolean
:nocov:.
- #perform_render(&block) ⇒ Object
- #render? ⇒ Boolean
- #to_component ⇒ Object
-
#type ⇒ Object
:nocov:.
Methods included from ActsAsComponent
compile!, extended, renders_templates
Methods included from ClassNameHelper
Class Method Details
.inherited(base) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/primer/forms/base_component.rb', line 10 def self.inherited(base) base_path = 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
#content ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/primer/forms/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:
46 47 48 |
# File 'lib/primer/forms/base_component.rb', line 46 def input? false end |
#perform_render(&block) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/primer/forms/base_component.rb', line 24 def perform_render(&block) return "" unless render? @__prf_content_block = block compile_and_render_template end |
#render? ⇒ Boolean
54 55 56 |
# File 'lib/primer/forms/base_component.rb', line 54 def render? true end |
#to_component ⇒ Object
50 51 52 |
# File 'lib/primer/forms/base_component.rb', line 50 def to_component self end |
#type ⇒ Object
:nocov:
41 42 43 |
# File 'lib/primer/forms/base_component.rb', line 41 def type :component end |