Module: Ilex::RailsExt::ActionView::Base
- Defined in:
- lib/ilex/rails_ext/action_view/base.rb
Instance Method Summary collapse
Instance Method Details
#capture(*args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ilex/rails_ext/action_view/base.rb', line 5 def capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } # if args.first&.respond_to? :ctx # value = args.first.ctx.children.to_s # end # We're only capturing the last returned arbre element # This uses that element to get the current context, and # get the html for the whole tree # We have to collect the children manually because # `content` is overridden if value.is_a? Arbre::Element value = value.arbre_context.children.to_s end if (string = buffer.presence || value) && string.is_a?(String) ERB::Util.html_escape string end end |