Module: AmberComponent::Rendering::InstanceMethods
- Included in:
- Base
- Defined in:
- lib/amber_component/rendering.rb
Overview
Instance methods for rendering.
Instance Method Summary collapse
- #nested_content(*args, &block) ⇒ String (also: #children)
- #render(&block) ⇒ String
-
#render_in(_context) ⇒ String
Method used internally by Rails to render an object passed to the ‘render` method.
- #safe_capture(*args) ⇒ Object
Instance Method Details
#nested_content(*args, &block) ⇒ String Also known as: children
106 107 108 109 110 111 |
# File 'lib/amber_component/rendering.rb', line 106 def nested_content(*args, &block) block_self = block.binding.receiver return block_self.safe_capture(*args, &block) if block_self.respond_to?(:safe_capture) safe_capture(*args, &block) end |
#render(&block) ⇒ String
87 88 89 90 91 |
# File 'lib/amber_component/rendering.rb', line 87 def render(&block) run_callbacks :render do compile_and_render(&block) end end |
#render_in(_context) ⇒ String
Method used internally by Rails to render an object passed to the ‘render` method.
render MyComponent.new(some: :attribute)
100 101 102 |
# File 'lib/amber_component/rendering.rb', line 100 def render_in(_context) render end |
#safe_capture(*args) ⇒ Object
114 115 116 117 118 |
# File 'lib/amber_component/rendering.rb', line 114 def safe_capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } buffer.presence || value.html_safe end |