Module: RailsComponents
- Defined in:
- lib/rails_components/html_helpers.rb,
lib/rails_components.rb,
lib/rails_components/configuration.rb
Overview
Defined Under Namespace
Modules: HtmlHelpers Classes: Configuration
Constant Summary collapse
- COMPONENT_RESERVED_WORDS =
%i(class return super).freeze
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
- #component(component_template, text_or_locals_with_block = nil, locals = nil, &block) ⇒ Object
- #component_content_tag(props, name, content_or_options_with_block = nil, options = nil, escape = true, &block) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/rails_components/configuration.rb', line 4 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
11 12 13 |
# File 'lib/rails_components/configuration.rb', line 11 def self.configure yield(configuration) if block_given? end |
Instance Method Details
#component(component_template, text_or_locals_with_block = nil, locals = nil, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rails_components.rb', line 7 def component(component_template, text_or_locals_with_block = nil, locals = nil, &block) if RailsComponents.configuration.template_directory component_template = [RailsComponents.configuration.template_directory, component_template].join('/') end if block_given? render({ layout: component_template, locals: component_locals(text_or_locals_with_block) }, &block) elsif text_or_locals_with_block.is_a?(Hash) && locals.nil? render(layout: component_template, locals: component_locals(text_or_locals_with_block)) {} else render(layout: component_template, locals: component_locals(locals)) { text_or_locals_with_block } end end |
#component_content_tag(props, name, content_or_options_with_block = nil, options = nil, escape = true, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/rails_components.rb', line 23 def component_content_tag(props, name, = nil, = nil, escape = true, &block) if block_given? = props.merge_html() if .is_a? Hash content_tag(name, , , escape, &block) else = props.merge_html() content_tag(name, , , escape, &block) end end |