Return <script> tags to add jQuery in Rails
555564
def include_jquery(options = { })
      options = { env: Rails.env.to_sym }.merge(options)
      JqueryCdn.local_url = proc { javascript_path("jquery.js") }
      JqueryCdn.include_jquery(options).html_safe
    end
1232058
def element_tags(element, options = {})
      if respond_to?(:tag_options)
        tag_options(element_tags_attributes(element, options))
      else
        # Rails 5.1 uses TagBuilder
        tag_builder.tag_options(element_tags_attributes(element, options))
      end
    end
996772
def tags(key = nil)
      if custom?
        tags = @data[:data][:sdk][:custom][:tags]
      else
        tags = @data[:data][key]
      end
      key ? tags[key] : tags
    end
1357115
def new
      @tag = Tag.new

      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @tag }
      end
    end
781678
def require_rails_script(script, description)
      # Check that we're actually within a rails project directory
      script_path = File.join(Loops.root, script)
      unless File.exists?(script_path)
        puts
        puts "Error: missing Rails #{description}: #{script}"
        puts "Are you sure current directory is a root of a Rails project?"
        puts "Current dir: #{Loops.root}"
        puts
        exit(1)
      end

      # Load the script
      require(script_path)
    end
1344843
def to_javascript_data(plugins):
    

    def escape(v):
        return re.sub(r'"', r'\\"', v)

    def dom_matchers(p):
        dom_matchers = p.get_matchers('dom')
        escaped_dom_matchers = []

        for dm in dom_matchers:
            check_statement, version_statement = dm

            escaped_dom_matchers.append({
                'check_statement': escape(check_statement),
                # Escape '' and not None
                'version_statement': escape(version_statement or ''),
            })

        return escaped_dom_matchers

    return [{'name': p.name, 'matchers': dom_matchers(p)}
            for p in plugins.with_dom_matchers()]
1189589
function(url, win, attributes) {
        var o = {
            id:   Y.guid(),
            type: TYPE_JS
        };

        if (attributes) {
            Y.mix(o, attributes);
        }

        o.src = url;

        return _node("script", o, win);
    }
241944
function() {
	var mappables = ["script" , "style"]
	for(var m in mappables) {
	  var which = mappables[m]
	  if($vars[which+'s']) {//if we have $vars["scripts"] or $vars["styles"]
		var page_scripts = $vars[which+'s'];
		var map_json = JSON.parse(fs.readFileSync($data_dir + "/common/"+which+"-mapping.json"));
		var mapped_scripts = [];
		for(var i in page_scripts) {
			if(page_scripts[i] in map_json) {
				if(typeof map_json[page_scripts[i]] == "string") mapped_scripts.push(map_json[page_scripts[i]])
				else if(typeof map_json[page_scripts[i]] == "object") //two or more scripts should be included for this to work, like dataTables, jQuery UI, etc ...
				{
					for(var m in map_json[page_scripts[i]])
						mapped_scripts.push(map_json[page_scripts[i]][m])
				}
			}
		}
		$vars[which+'s'] = mapped_scripts;

		if(('ie_'+which+'s') in $vars) {
			var ie_scripts = $vars['ie_'+which+'s'];//ie_scripts || ie_styles
			var ie_mapped_scripts = [];
			for(var i in ie_scripts) if(map_json[ie_scripts[i].name])
			{
				ie_mapped_scripts.push({"version" : ie_scripts[i].version , "file_name" : map_json[ie_scripts[i].name]})
			}

			$vars['ie_'+which+'s'] = ie_mapped_scripts
		}
	  }
	}
 }
589437
def add_tags(jobflow_id, tags)
      params = {
        :operation => 'AddTags',
        :resource_id => jobflow_id,
        :tags => tags
      }
      aws_result = @aws_request.submit(params)
      yield aws_result if block_given?
    end
1350722
def template_include_tag(*sources)
      options = sources.extract_options!
      sources.collect do |source|
        template_finder = lambda do |partial|
          if ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 2
            lookup_context.find(source, [], partial)
          else # Rails 3.2 and higher
            lookup_context.find(source, [], partial, [], { formats: [:html] })
          end
        end

        template = template_finder.call(true) rescue template_finder.call(false)
        template_id = (Stache.include_path_in_id) ? source.gsub("/", '_') : source.to_s.split("/").last
        content_tag(:script, template.source.html_safe, options.reverse_merge(type: 'text/html', id: template_id.dasherize.underscore))

      end.join("\n").html_safe
    end
91369
def google_tag_manager_script_tag(label)
      container_id = GtmRails::Config.container_ids[label]

      return '' if container_id.blank?

      <<-HTML.strip_heredoc.html_safe
        <!-- Google Tag Manager -->
        <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
        'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','#{container_id}');</script>
        <!-- End Google Tag Manager -->
      HTML
    end
963147
def tags_get(params={})
      options = create_params(params)
      tags = self.class.get('/tags/get', options)['tags']['tag']
      tags = [] if tags.nil?
      tags = [*tags]
      tags.map { |p| Tag.new(Util.symbolize_keys(p)) }
    end
217313
def visit_tag(node)
      return unless enabled?

      visit_script(node) ||
        if node.parsed_attributes.contains_instance_variables?
          record_lint(node, "Avoid using instance variables in #{file_types} views")
        end
    end
183360
def jquery_js(version=None, migrate=False):
    ''''''
    version = version or settings.JQUERY_VERSION
    suffix = '.min' if not settings.DEBUG else ''
    libs = [js_lib('jquery-%s%s.js' % (version, suffix))]
    if _boolean(migrate):
        libs.append(js_lib('jquery-migrate-%s%s.js' % (JQUERY_MIGRATE_VERSION, suffix)))
    return '\n'.join(libs)
1124468
public function headerDeferJavascripts()
    {
        add_filter('script_loader_tag', function ($tag, $handle) {
            // Main WP jQuery is not concerned
            if (strpos($tag, '/wp-includes/js/jquery/jquery')) {
                return $tag;
            }

            // Defer on MSIE is not permitted
            if (isset($_SERVER['HTTP_USER_AGENT']) && false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 9.')) {
                return $tag;
            }

            return str_replace(' src', ' defer src', $tag);
        }, 10, 2);
    }
718348
function() {
    var jsPath, scripts, i;
    if (_document.currentScript && (jsPath = _document.currentScript.src)) {
      return jsPath;
    }
    scripts = _document.getElementsByTagName("script");
    if (scripts.length === 1) {
      return scripts[0].src || undefined;
    }
    if ("readyState" in (scripts[0] || document.createElement("script"))) {
      for (i = scripts.length; i--; ) {
        if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
          return jsPath;
        }
      }
    }
    if (_document.readyState === "loading" && (jsPath = scripts[scripts.length - 1].src)) {
      return jsPath;
    }
    if (jsPath = _getCurrentScriptUrlFromError()) {
      return jsPath;
    }
    return undefined;
  }
1173055
function filterScriptTag(html, config) {
    var result;

    if (config.removeMatchedTag) {
        result = html.replace(REGEXP_TAG_SCRIPT, '');
    } else {
        result = html.replace(REGEXP_TAG_SCRIPT, function(body) {
            return escapeTags(body);
        });
    }

    return result;
}