Module: BigpipeRails::Helper::InstanceMethods
- Defined in:
- lib/bigpipe_rails/helper.rb
Instance Method Summary collapse
-
#bigpipe(container, opts = {}, &block) ⇒ Object
helper method to put Bigpipe on the page.
-
#bigpipes ⇒ Object
accessor.
-
#render_bigpipe ⇒ Object
render the collection.
Instance Method Details
#bigpipe(container, opts = {}, &block) ⇒ Object
helper method to put Bigpipe on the page
7 8 9 10 11 12 13 |
# File 'lib/bigpipe_rails/helper.rb', line 7 def bigpipe(container, opts = {}, &block) @bigpipe_js = [] @bigpipe_css = [] opts[:append] ||= false opts[:container] = container self.bigpipes << [opts, block] end |
#bigpipes ⇒ Object
accessor
15 16 17 |
# File 'lib/bigpipe_rails/helper.rb', line 15 def bigpipes @bigpipes ||= [] end |
#render_bigpipe ⇒ Object
render the collection
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bigpipe_rails/helper.rb', line 19 def render_bigpipe @bigpipes.each do |pipe| opts, block = pipe # we actually run the block here - # TODO: use em-synchrony and/or our own Fiber implementation opts[:content] = capture(&block) # TODO: we are re-escaping here for some reason - should be able to use javascript_tag # helper, need to see why it doesn't work data = %Q{ <script type="text/javascript"> <![CDATA[ BigPipe.add_pagelet(#{opts.to_json}); ]]> </script> } self.output_buffer.safe_concat(data) end "" end |