Sha256: 9fe4ba4ac725e8c1a21af935ef8f803c5a798b064f0608a186c4364c1acf4a24
Contents?: true
Size: 890 Bytes
Versions: 6
Compression:
Stored size: 890 Bytes
Contents
module PageletRails::Concerns::ResponseWrapper extend ActiveSupport::Concern def process_action *args super.tap do if params[:target_container] && action_has_layout? && request.format.js? # wrap to js only if requested js response.content_type = 'text/javascript' html = self.response_body.reduce('') { |memo, body| memo << body memo } if html.match(/^\s*</) # the body could be javascript, make sure it's html before wrapping id = ActionController::Base.helpers.escape_javascript params[:target_container] js = ActionController::Base.helpers.escape_javascript html html = ActionController::Base.helpers.raw( "PageletRails.pageletArrived('#{id}', '#{js}');" ) self.response_body = [html] end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems