Method: Padrino::Helpers::AssetTagHelpers#javascript_include_tag

Defined in:
padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb

#javascript_include_tag(*sources, options = {}) ⇒ String

Returns a html script tag for each of the sources provided. You can pass in the filename without extension or a symbol and we search it in your appname.public_folder like app/public/javascript for inclusion. You can provide also a full path.

Examples:

javascript_include_tag 'application', :extjs

Parameters:

  • sources (Array<String>)

    Splat of js source paths

  • options (Hash) (defaults to: {})

    The html options for the script tag

Returns:

  • (String)

    Script tag for sources with specified options.

[View source] [View on GitHub]

266
267
268
269
270
271
272
273
# File 'padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb', line 266

def javascript_include_tag(*sources)
  options = {
    :type => 'text/javascript'
  }.update(sources.last.is_a?(Hash) ? Utils.symbolize_keys(sources.pop) : {})
  sources.flatten.inject(SafeBuffer.new) do |all,source|
    all << (:script, nil, { :src => asset_path(:js, source) }.update(options))
  end
end