Sha256: ebabede6eb17aaacf1991ff5901b6c5e961441849e5c0dc58a392f9b565d431d
Contents?: true
Size: 1.32 KB
Versions: 12
Compression:
Stored size: 1.32 KB
Contents
require 'active_tools/misc/uniq_content' module ActiveTools module Misc DEFAULT_JS_FLOW_KEY = :_script_flow end module OnLoadActionController def _render_template(options) if lookup_context.rendered_format == :js super + uniq_content_storage.render_content(Misc::DEFAULT_JS_FLOW_KEY) else super end end end module OnLoadActionView def script(*args, &block) options = args.extract_options! content = args.first if content || block_given? if block_given? content = capture(&block) end if content case request.format when Mime::JS then uniq_content_storage.append_content(content, Misc::DEFAULT_JS_FLOW_KEY) nil when Mime::HTML then volume = options.delete(:volume) unless uniq_content_storage.remembered?(content, volume) flow = uniq_content_storage.remember(content, volume) options[:javascript_tag] == false ? flow : javascript_tag(flow, options) end end end end end def script_for(identifier, *args, &block) options = args.extract_options! content_for(identifier) do script(args, options.merge(:volume => identifier), &block) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems