mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Added that both AssetHelper#stylesheet_link_tag and AssetHelper#javascript_include_tag now accept an option hash as the last parameter, so you can do stuff like: stylesheet_link_tag "style", :media => "all"
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1281 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Added that both AssetHelper#stylesheet_link_tag and AssetHelper#javascript_include_tag now accept an option hash as the last parameter, so you can do stuff like: stylesheet_link_tag "style", :media => "all"
|
||||
|
||||
* Added FormTagHelper#image_submit_tag for making submit buttons that uses images
|
||||
|
||||
* Added the option of specifying a RAILS_ASSET_HOST that will then be used by all the asset helpers. This enables you to easily offload static content like javascripts and images to a separate server tuned just for that.
|
||||
|
||||
@@ -39,9 +39,10 @@ module ActionView
|
||||
# <script type="text/javascript" src="/javascripts/common.javascript"></script>
|
||||
# <script type="text/javascript" src="/elsewhere/cools.js"></script>
|
||||
def javascript_include_tag(*sources)
|
||||
options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
|
||||
sources.collect { |source|
|
||||
source = javascript_path(source)
|
||||
content_tag("script", "", "type" => "text/javascript", "src" => source)
|
||||
content_tag("script", "", { "type" => "text/javascript", "src" => source }.merge(options))
|
||||
}.join("\n")
|
||||
end
|
||||
|
||||
@@ -57,13 +58,17 @@ module ActionView
|
||||
# stylesheet_link_tag "style" # =>
|
||||
# <link href="/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />
|
||||
#
|
||||
# stylesheet_link_tag "style", :media => "all" # =>
|
||||
# <link href="/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" />
|
||||
#
|
||||
# stylesheet_link_tag "random.styles", "/css/stylish" # =>
|
||||
# <link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />
|
||||
# <link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />
|
||||
def stylesheet_link_tag(*sources)
|
||||
options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
|
||||
sources.collect { |source|
|
||||
source = stylesheet_path(source)
|
||||
tag("link", "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => source)
|
||||
tag("link", { "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => source }.merge(options))
|
||||
}.join("\n")
|
||||
end
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ class AssetTagHelperTest < Test::Unit::TestCase
|
||||
|
||||
JavascriptIncludeToTag = {
|
||||
%(javascript_include_tag("xmlhr")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>),
|
||||
%(javascript_include_tag("xmlhr", :lang => "vbscript")) => %(<script lang="vbscript" src="/javascripts/xmlhr.js" type="text/javascript"></script>),
|
||||
%(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/elsewhere/cools.js" type="text/javascript"></script>),
|
||||
}
|
||||
|
||||
@@ -44,6 +45,7 @@ class AssetTagHelperTest < Test::Unit::TestCase
|
||||
|
||||
StyleLinkToTag = {
|
||||
%(stylesheet_link_tag("style")) => %(<link href="/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />),
|
||||
%(stylesheet_link_tag("style", :media => "all")) => %(<link href="/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" />),
|
||||
%(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user