From 6b77df0ade304e3856c8c07c93e2a8cde3c040f0 Mon Sep 17 00:00:00 2001 From: Grzegorz Witek Date: Sun, 8 Nov 2015 21:39:39 +0800 Subject: Allow `host` option in javscript and css helpers Now both `javascript_include_tag` and `stylesheet_tag` can accept `host` option to provide custom host for the asset --- actionview/CHANGELOG.md | 4 ++++ actionview/lib/action_view/helpers/asset_tag_helper.rb | 4 ++-- actionview/test/template/asset_tag_helper_test.rb | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index e5f5961326..1db37033b7 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,7 @@ +* Allow `host` option in `javascript_include_tag` and `stylesheet_tag` helpers + + *Grzegorz Witek* + * Restrict `url_for :back` to valid, non-JavaScript URLs. GH#14444 *Damien Burke* diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb index fa46a22500..2ffed6b395 100644 --- a/actionview/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb @@ -55,7 +55,7 @@ module ActionView # # => def javascript_include_tag(*sources) options = sources.extract_options!.stringify_keys - path_options = options.extract!('protocol', 'extname').symbolize_keys + path_options = options.extract!('protocol', 'extname', 'host').symbolize_keys sources.uniq.map { |source| tag_options = { "src" => path_to_javascript(source, path_options) @@ -91,7 +91,7 @@ module ActionView # # def stylesheet_link_tag(*sources) options = sources.extract_options!.stringify_keys - path_options = options.extract!('protocol').symbolize_keys + path_options = options.extract!('protocol', 'host').symbolize_keys sources.uniq.map { |source| tag_options = { diff --git a/actionview/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb index 496b33b35e..a63ac442cd 100644 --- a/actionview/test/template/asset_tag_helper_test.rb +++ b/actionview/test/template/asset_tag_helper_test.rb @@ -97,6 +97,7 @@ class AssetTagHelperTest < ActionView::TestCase %(javascript_include_tag("bank")) => %(), %(javascript_include_tag("bank.js")) => %(), %(javascript_include_tag("bank", :lang => "vbscript")) => %(), + %(javascript_include_tag("bank", :host => "assets.example.com")) => %(), %(javascript_include_tag("http://example.com/all")) => %(), %(javascript_include_tag("http://example.com/all.js")) => %(), @@ -141,6 +142,7 @@ class AssetTagHelperTest < ActionView::TestCase %(stylesheet_link_tag("/elsewhere/file")) => %(), %(stylesheet_link_tag("subdir/subdir")) => %(), %(stylesheet_link_tag("bank", :media => "all")) => %(), + %(stylesheet_link_tag("bank", :host => "assets.example.com")) => %(), %(stylesheet_link_tag("http://www.example.com/styles/style")) => %(), %(stylesheet_link_tag("http://www.example.com/styles/style.css")) => %(), -- cgit v1.2.3