actionview 4.2.11.3 → 5.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionview might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +136 -255
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -3
- data/lib/action_view.rb +1 -1
- data/lib/action_view/base.rb +14 -2
- data/lib/action_view/dependency_tracker.rb +46 -15
- data/lib/action_view/digestor.rb +13 -9
- data/lib/action_view/flows.rb +1 -1
- data/lib/action_view/gem_version.rb +4 -4
- data/lib/action_view/helpers/asset_tag_helper.rb +15 -5
- data/lib/action_view/helpers/asset_url_helper.rb +51 -12
- data/lib/action_view/helpers/atom_feed_helper.rb +5 -4
- data/lib/action_view/helpers/cache_helper.rb +75 -20
- data/lib/action_view/helpers/capture_helper.rb +3 -2
- data/lib/action_view/helpers/controller_helper.rb +1 -0
- data/lib/action_view/helpers/date_helper.rb +39 -10
- data/lib/action_view/helpers/debug_helper.rb +1 -1
- data/lib/action_view/helpers/form_helper.rb +81 -35
- data/lib/action_view/helpers/form_options_helper.rb +74 -35
- data/lib/action_view/helpers/form_tag_helper.rb +46 -19
- data/lib/action_view/helpers/javascript_helper.rb +4 -4
- data/lib/action_view/helpers/number_helper.rb +10 -12
- data/lib/action_view/helpers/record_tag_helper.rb +12 -99
- data/lib/action_view/helpers/rendering_helper.rb +2 -2
- data/lib/action_view/helpers/sanitize_helper.rb +1 -2
- data/lib/action_view/helpers/tag_helper.rb +20 -13
- data/lib/action_view/helpers/tags/base.rb +33 -28
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +2 -30
- data/lib/action_view/helpers/tags/collection_helpers.rb +28 -0
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +1 -9
- data/lib/action_view/helpers/tags/file_field.rb +15 -0
- data/lib/action_view/helpers/tags/label.rb +1 -1
- data/lib/action_view/helpers/tags/placeholderable.rb +1 -1
- data/lib/action_view/helpers/tags/search_field.rb +12 -9
- data/lib/action_view/helpers/tags/text_field.rb +0 -1
- data/lib/action_view/helpers/tags/translator.rb +1 -1
- data/lib/action_view/helpers/text_helper.rb +25 -9
- data/lib/action_view/helpers/translation_helper.rb +56 -26
- data/lib/action_view/helpers/url_helper.rb +40 -65
- data/lib/action_view/layouts.rb +11 -10
- data/lib/action_view/lookup_context.rb +14 -40
- data/lib/action_view/model_naming.rb +1 -1
- data/lib/action_view/path_set.rb +15 -18
- data/lib/action_view/railtie.rb +20 -3
- data/lib/action_view/record_identifier.rb +44 -19
- data/lib/action_view/renderer/abstract_renderer.rb +1 -1
- data/lib/action_view/renderer/partial_renderer.rb +27 -26
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +70 -0
- data/lib/action_view/renderer/renderer.rb +2 -6
- data/lib/action_view/renderer/streaming_template_renderer.rb +1 -1
- data/lib/action_view/renderer/template_renderer.rb +12 -11
- data/lib/action_view/rendering.rb +8 -5
- data/lib/action_view/routing_url_for.rb +18 -6
- data/lib/action_view/template.rb +50 -13
- data/lib/action_view/template/error.rb +14 -7
- data/lib/action_view/template/handlers.rb +3 -3
- data/lib/action_view/template/handlers/erb.rb +25 -0
- data/lib/action_view/template/handlers/raw.rb +1 -1
- data/lib/action_view/template/resolver.rb +36 -58
- data/lib/action_view/template/types.rb +1 -1
- data/lib/action_view/test_case.rb +13 -8
- data/lib/action_view/testing/resolvers.rb +3 -4
- data/lib/action_view/view_paths.rb +6 -22
- metadata +17 -14
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -9,11 +9,11 @@ used to inline short Ruby snippets inside HTML), and XML Builder.
|
|
9
9
|
|
10
10
|
The latest version of Action View can be installed with RubyGems:
|
11
11
|
|
12
|
-
|
12
|
+
$ gem install actionview
|
13
13
|
|
14
14
|
Source code can be downloaded as part of the Rails project on GitHub
|
15
15
|
|
16
|
-
* https://github.com/rails/rails/tree/
|
16
|
+
* https://github.com/rails/rails/tree/master/actionview
|
17
17
|
|
18
18
|
|
19
19
|
== License
|
@@ -36,4 +36,3 @@ Bug reports can be filed for the Ruby on Rails project here:
|
|
36
36
|
Feature requests should be discussed on the rails-core mailing list here:
|
37
37
|
|
38
38
|
* https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
|
39
|
-
|
data/lib/action_view.rb
CHANGED
data/lib/action_view/base.rb
CHANGED
@@ -70,6 +70,14 @@ module ActionView #:nodoc:
|
|
70
70
|
# Headline: <%= headline %>
|
71
71
|
# First name: <%= person.first_name %>
|
72
72
|
#
|
73
|
+
# The local variables passed to sub templates can be accessed as a hash using the <tt>local_assigns</tt> hash. This lets you access the
|
74
|
+
# variables as:
|
75
|
+
#
|
76
|
+
# Headline: <%= local_assigns[:headline] %>
|
77
|
+
#
|
78
|
+
# This is useful in cases where you aren't sure if the local variable has been assigned. Alternatively, you could also use
|
79
|
+
# <tt>defined? headline</tt> to first check if the variable has been assigned before using it.
|
80
|
+
#
|
73
81
|
# === Template caching
|
74
82
|
#
|
75
83
|
# By default, Rails will compile each template to a method in order to render it. When you alter a template,
|
@@ -126,8 +134,8 @@ module ActionView #:nodoc:
|
|
126
134
|
# end
|
127
135
|
# end
|
128
136
|
#
|
129
|
-
# For more information on Builder please consult the
|
130
|
-
# code
|
137
|
+
# For more information on Builder please consult the {source
|
138
|
+
# code}[https://github.com/jimweirich/builder].
|
131
139
|
class Base
|
132
140
|
include Helpers, ::ERB::Util, Context
|
133
141
|
|
@@ -153,6 +161,10 @@ module ActionView #:nodoc:
|
|
153
161
|
cattr_accessor :raise_on_missing_translations
|
154
162
|
@@raise_on_missing_translations = false
|
155
163
|
|
164
|
+
# Specify whether submit_tag should automatically disable on click
|
165
|
+
cattr_accessor :automatically_disable_submit_tag
|
166
|
+
@@automatically_disable_submit_tag = true
|
167
|
+
|
156
168
|
class_attribute :_routes
|
157
169
|
class_attribute :logger
|
158
170
|
|
@@ -1,16 +1,18 @@
|
|
1
|
-
require '
|
1
|
+
require 'concurrent/map'
|
2
|
+
require 'action_view/path_set'
|
2
3
|
|
3
4
|
module ActionView
|
4
5
|
class DependencyTracker # :nodoc:
|
5
|
-
@trackers =
|
6
|
+
@trackers = Concurrent::Map.new
|
6
7
|
|
7
|
-
def self.find_dependencies(name, template)
|
8
|
+
def self.find_dependencies(name, template, view_paths = nil)
|
8
9
|
tracker = @trackers[template.handler]
|
10
|
+
return [] unless tracker.present?
|
9
11
|
|
10
|
-
if tracker.
|
11
|
-
tracker.call(name, template)
|
12
|
+
if tracker.respond_to?(:supports_view_paths?) && tracker.supports_view_paths?
|
13
|
+
tracker.call(name, template, view_paths)
|
12
14
|
else
|
13
|
-
|
15
|
+
tracker.call(name, template)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -76,12 +78,22 @@ module ActionView
|
|
76
78
|
(?:#{STRING}|#{VARIABLE_OR_METHOD_CHAIN}) # finally, the dependency name of interest
|
77
79
|
/xm
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
LAYOUT_DEPENDENCY = /\A
|
82
|
+
(?:\s*\(?\s*) # optional opening paren surrounded by spaces
|
83
|
+
(?:.*?#{LAYOUT_HASH_KEY}) # check if the line has layout key declaration
|
84
|
+
(?:#{STRING}|#{VARIABLE_OR_METHOD_CHAIN}) # finally, the dependency name of interest
|
85
|
+
/xm
|
86
|
+
|
87
|
+
def self.supports_view_paths? # :nodoc:
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.call(name, template, view_paths = nil)
|
92
|
+
new(name, template, view_paths).dependencies
|
81
93
|
end
|
82
94
|
|
83
|
-
def initialize(name, template)
|
84
|
-
@name, @template = name, template
|
95
|
+
def initialize(name, template, view_paths = nil)
|
96
|
+
@name, @template, @view_paths = name, template, view_paths
|
85
97
|
end
|
86
98
|
|
87
99
|
def dependencies
|
@@ -106,15 +118,20 @@ module ActionView
|
|
106
118
|
render_calls = source.split(/\brender\b/).drop(1)
|
107
119
|
|
108
120
|
render_calls.each do |arguments|
|
109
|
-
arguments
|
110
|
-
|
111
|
-
add_static_dependency(render_dependencies, Regexp.last_match[:static])
|
112
|
-
end
|
121
|
+
add_dependencies(render_dependencies, arguments, LAYOUT_DEPENDENCY)
|
122
|
+
add_dependencies(render_dependencies, arguments, RENDER_ARGUMENTS)
|
113
123
|
end
|
114
124
|
|
115
125
|
render_dependencies.uniq
|
116
126
|
end
|
117
127
|
|
128
|
+
def add_dependencies(render_dependencies, arguments, pattern)
|
129
|
+
arguments.scan(pattern) do
|
130
|
+
add_dynamic_dependency(render_dependencies, Regexp.last_match[:dynamic])
|
131
|
+
add_static_dependency(render_dependencies, Regexp.last_match[:static])
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
118
135
|
def add_dynamic_dependency(dependencies, dependency)
|
119
136
|
if dependency
|
120
137
|
dependencies << "#{dependency.pluralize}/#{dependency.singularize}"
|
@@ -131,8 +148,22 @@ module ActionView
|
|
131
148
|
end
|
132
149
|
end
|
133
150
|
|
151
|
+
def resolve_directories(wildcard_dependencies)
|
152
|
+
return [] unless @view_paths
|
153
|
+
|
154
|
+
wildcard_dependencies.each_with_object([]) do |query, templates|
|
155
|
+
@view_paths.find_all_with_query(query).each do |template|
|
156
|
+
templates << "#{File.dirname(query)}/#{File.basename(template).split('.').first}"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
134
161
|
def explicit_dependencies
|
135
|
-
source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
|
162
|
+
dependencies = source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
|
163
|
+
|
164
|
+
wildcards, explicits = dependencies.partition { |dependency| dependency[-1] == '*' }
|
165
|
+
|
166
|
+
(explicits + resolve_directories(wildcards)).uniq
|
136
167
|
end
|
137
168
|
end
|
138
169
|
|
data/lib/action_view/digestor.rb
CHANGED
@@ -1,18 +1,25 @@
|
|
1
|
-
require '
|
1
|
+
require 'concurrent/map'
|
2
2
|
require 'action_view/dependency_tracker'
|
3
3
|
require 'monitor'
|
4
4
|
|
5
5
|
module ActionView
|
6
6
|
class Digestor
|
7
7
|
cattr_reader(:cache)
|
8
|
-
@@cache =
|
8
|
+
@@cache = Concurrent::Map.new
|
9
9
|
@@digest_monitor = Monitor.new
|
10
10
|
|
11
|
+
class PerRequestDigestCacheExpiry < Struct.new(:app) # :nodoc:
|
12
|
+
def call(env)
|
13
|
+
ActionView::Digestor.cache.clear
|
14
|
+
app.call(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
11
18
|
class << self
|
12
19
|
# Supported options:
|
13
20
|
#
|
14
21
|
# * <tt>name</tt> - Template name
|
15
|
-
# * <tt>finder</tt> - An instance of ActionView::LookupContext
|
22
|
+
# * <tt>finder</tt> - An instance of <tt>ActionView::LookupContext</tt>
|
16
23
|
# * <tt>dependencies</tt> - An array of dependent views
|
17
24
|
# * <tt>partial</tt> - Specifies whether the template is a partial
|
18
25
|
def digest(options)
|
@@ -21,7 +28,7 @@ module ActionView
|
|
21
28
|
cache_key = ([ options[:name], options[:finder].details_key.hash ].compact + Array.wrap(options[:dependencies])).join('.')
|
22
29
|
|
23
30
|
# this is a correctly done double-checked locking idiom
|
24
|
-
# (
|
31
|
+
# (Concurrent::Map's lookups have volatile semantics)
|
25
32
|
@@cache[cache_key] || @@digest_monitor.synchronize do
|
26
33
|
@@cache.fetch(cache_key) do # re-check under lock
|
27
34
|
compute_and_store_digest(cache_key, options)
|
@@ -41,10 +48,7 @@ module ActionView
|
|
41
48
|
Digestor
|
42
49
|
end
|
43
50
|
|
44
|
-
|
45
|
-
# Store the actual digest if config.cache_template_loading is true
|
46
|
-
@@cache[cache_key] = stored_digest = digest if ActionView::Resolver.caching?
|
47
|
-
digest
|
51
|
+
@@cache[cache_key] = stored_digest = klass.new(options).digest
|
48
52
|
ensure
|
49
53
|
# something went wrong or ActionView::Resolver.caching? is false, make sure not to corrupt the @@cache
|
50
54
|
@@cache.delete_pair(cache_key, false) if pre_stored && !stored_digest
|
@@ -68,7 +72,7 @@ module ActionView
|
|
68
72
|
end
|
69
73
|
|
70
74
|
def dependencies
|
71
|
-
DependencyTracker.find_dependencies(name, template)
|
75
|
+
DependencyTracker.find_dependencies(name, template, finder.view_paths)
|
72
76
|
rescue ActionView::MissingTemplate
|
73
77
|
logger.try :error, " '#{name}' file doesn't exist, so no dependencies"
|
74
78
|
[]
|
data/lib/action_view/flows.rb
CHANGED
@@ -55,12 +55,12 @@ module ActionView
|
|
55
55
|
# # => <script src="http://www.example.com/xmlhr.js"></script>
|
56
56
|
def javascript_include_tag(*sources)
|
57
57
|
options = sources.extract_options!.stringify_keys
|
58
|
-
path_options = options.extract!('protocol', 'extname').symbolize_keys
|
58
|
+
path_options = options.extract!('protocol', 'extname', 'host').symbolize_keys
|
59
59
|
sources.uniq.map { |source|
|
60
60
|
tag_options = {
|
61
61
|
"src" => path_to_javascript(source, path_options)
|
62
62
|
}.merge!(options)
|
63
|
-
content_tag(
|
63
|
+
content_tag("script".freeze, "", tag_options)
|
64
64
|
}.join("\n").html_safe
|
65
65
|
end
|
66
66
|
|
@@ -91,7 +91,7 @@ module ActionView
|
|
91
91
|
# # <link href="/css/stylish.css" media="screen" rel="stylesheet" />
|
92
92
|
def stylesheet_link_tag(*sources)
|
93
93
|
options = sources.extract_options!.stringify_keys
|
94
|
-
path_options = options.extract!('protocol').symbolize_keys
|
94
|
+
path_options = options.extract!('protocol', 'host').symbolize_keys
|
95
95
|
|
96
96
|
sources.uniq.map { |source|
|
97
97
|
tag_options = {
|
@@ -136,7 +136,7 @@ module ActionView
|
|
136
136
|
tag(
|
137
137
|
"link",
|
138
138
|
"rel" => tag_options[:rel] || "alternate",
|
139
|
-
"type" => tag_options[:type] || Mime
|
139
|
+
"type" => tag_options[:type] || Mime[type].to_s,
|
140
140
|
"title" => tag_options[:title] || type.to_s.upcase,
|
141
141
|
"href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options
|
142
142
|
)
|
@@ -205,8 +205,11 @@ module ActionView
|
|
205
205
|
# # => <img alt="Icon" height="32" src="/icons/icon.gif" width="32" />
|
206
206
|
# image_tag("/icons/icon.gif", class: "menu_icon")
|
207
207
|
# # => <img alt="Icon" class="menu_icon" src="/icons/icon.gif" />
|
208
|
+
# image_tag("/icons/icon.gif", data: { title: 'Rails Application' })
|
209
|
+
# # => <img data-title="Rails Application" src="/icons/icon.gif" />
|
208
210
|
def image_tag(source, options={})
|
209
211
|
options = options.symbolize_keys
|
212
|
+
check_for_image_tag_errors(options)
|
210
213
|
|
211
214
|
src = options[:src] = path_to_image(source)
|
212
215
|
|
@@ -236,7 +239,7 @@ module ActionView
|
|
236
239
|
# image_alt('underscored_file_name.png')
|
237
240
|
# # => Underscored file name
|
238
241
|
def image_alt(src)
|
239
|
-
File.basename(src, '.*').sub(/-[[:xdigit:]]{32
|
242
|
+
File.basename(src, '.*'.freeze).sub(/-[[:xdigit:]]{32}\z/, ''.freeze).tr('-_'.freeze, ' '.freeze).capitalize
|
240
243
|
end
|
241
244
|
|
242
245
|
# Returns an HTML video tag for the +sources+. If +sources+ is a string,
|
@@ -318,12 +321,19 @@ module ActionView
|
|
318
321
|
end
|
319
322
|
|
320
323
|
def extract_dimensions(size)
|
324
|
+
size = size.to_s
|
321
325
|
if size =~ %r{\A\d+x\d+\z}
|
322
326
|
size.split('x')
|
323
327
|
elsif size =~ %r{\A\d+\z}
|
324
328
|
[size, size]
|
325
329
|
end
|
326
330
|
end
|
331
|
+
|
332
|
+
def check_for_image_tag_errors(options)
|
333
|
+
if options[:size] && (options[:height] || options[:width])
|
334
|
+
raise ArgumentError, "Cannot pass a :size option with a :height or :width option"
|
335
|
+
end
|
336
|
+
end
|
327
337
|
end
|
328
338
|
end
|
329
339
|
end
|
@@ -31,26 +31,33 @@ module ActionView
|
|
31
31
|
# stylesheet_link_tag("application")
|
32
32
|
# # => <link href="http://assets.example.com/assets/application.css" media="screen" rel="stylesheet" />
|
33
33
|
#
|
34
|
-
# Browsers
|
35
|
-
# host
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
34
|
+
# Browsers open a limited number of simultaneous connections to a single
|
35
|
+
# host. The exact number varies by browser and version. This limit may cause
|
36
|
+
# some asset downloads to wait for previous assets to finish before they can
|
37
|
+
# begin. You can use the <tt>%d</tt> wildcard in the +asset_host+ to
|
38
|
+
# distribute the requests over four hosts. For example,
|
39
|
+
# <tt>assets%d.example.com<tt> will spread the asset requests over
|
40
|
+
# "assets0.example.com", ..., "assets3.example.com".
|
41
41
|
#
|
42
42
|
# image_tag("rails.png")
|
43
43
|
# # => <img alt="Rails" src="http://assets0.example.com/assets/rails.png" />
|
44
44
|
# stylesheet_link_tag("application")
|
45
45
|
# # => <link href="http://assets2.example.com/assets/application.css" media="screen" rel="stylesheet" />
|
46
46
|
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
47
|
+
# This may improve the asset loading performance of your application.
|
48
|
+
# It is also possible the combination of additional connection overhead
|
49
|
+
# (DNS, SSL) and the overall browser connection limits may result in this
|
50
|
+
# solution being slower. You should be sure to measure your actual
|
51
|
+
# performance across targeted browsers both before and after this change.
|
52
|
+
#
|
53
|
+
# To implement the corresponding hosts you can either setup four actual
|
54
|
+
# hosts or use wildcard DNS to CNAME the wildcard to a single asset host.
|
55
|
+
# You can read more about setting up your DNS CNAME records from your ISP.
|
50
56
|
#
|
51
57
|
# Note: This is purely a browser performance optimization and is not meant
|
52
58
|
# for server load balancing. See http://www.die.net/musings/page_load_time/
|
53
|
-
# for background.
|
59
|
+
# for background and http://www.browserscope.org/?category=network for
|
60
|
+
# connection limit data.
|
54
61
|
#
|
55
62
|
# Alternatively, you can exert more control over the asset host by setting
|
56
63
|
# +asset_host+ to a proc like this:
|
@@ -121,11 +128,13 @@ module ActionView
|
|
121
128
|
# asset_path "application", type: :stylesheet # => /assets/application.css
|
122
129
|
# asset_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
|
123
130
|
def asset_path(source, options = {})
|
131
|
+
raise ArgumentError, "nil is not a valid asset source" if source.nil?
|
132
|
+
|
124
133
|
source = source.to_s
|
125
134
|
return "" unless source.present?
|
126
135
|
return source if source =~ URI_REGEXP
|
127
136
|
|
128
|
-
tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, '')
|
137
|
+
tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, ''.freeze)
|
129
138
|
|
130
139
|
if extname = compute_asset_extname(source, options)
|
131
140
|
source = "#{source}#{extname}"
|
@@ -248,6 +257,11 @@ module ActionView
|
|
248
257
|
|
249
258
|
# Computes the full URL to a JavaScript asset in the public javascripts directory.
|
250
259
|
# This will use +javascript_path+ internally, so most of their behaviors will be the same.
|
260
|
+
# Since +javascript_url+ is based on +asset_url+ method you can set :host options. If :host
|
261
|
+
# options is set, it overwrites global +config.action_controller.asset_host+ setting.
|
262
|
+
#
|
263
|
+
# javascript_url "js/xmlhr.js", host: "http://stage.example.com" # => http://stage.example.com/assets/dir/xmlhr.js
|
264
|
+
#
|
251
265
|
def javascript_url(source, options = {})
|
252
266
|
url_to_asset(source, {type: :javascript}.merge!(options))
|
253
267
|
end
|
@@ -270,6 +284,11 @@ module ActionView
|
|
270
284
|
|
271
285
|
# Computes the full URL to a stylesheet asset in the public stylesheets directory.
|
272
286
|
# This will use +stylesheet_path+ internally, so most of their behaviors will be the same.
|
287
|
+
# Since +stylesheet_url+ is based on +asset_url+ method you can set :host options. If :host
|
288
|
+
# options is set, it overwrites global +config.action_controller.asset_host+ setting.
|
289
|
+
#
|
290
|
+
# stylesheet_url "css/style.css", host: "http://stage.example.com" # => http://stage.example.com/css/style.css
|
291
|
+
#
|
273
292
|
def stylesheet_url(source, options = {})
|
274
293
|
url_to_asset(source, {type: :stylesheet}.merge!(options))
|
275
294
|
end
|
@@ -295,6 +314,11 @@ module ActionView
|
|
295
314
|
|
296
315
|
# Computes the full URL to an image asset.
|
297
316
|
# This will use +image_path+ internally, so most of their behaviors will be the same.
|
317
|
+
# Since +image_url+ is based on +asset_url+ method you can set :host options. If :host
|
318
|
+
# options is set, it overwrites global +config.action_controller.asset_host+ setting.
|
319
|
+
#
|
320
|
+
# image_url "edit.png", host: "http://stage.example.com" # => http://stage.example.com/edit.png
|
321
|
+
#
|
298
322
|
def image_url(source, options = {})
|
299
323
|
url_to_asset(source, {type: :image}.merge!(options))
|
300
324
|
end
|
@@ -316,6 +340,11 @@ module ActionView
|
|
316
340
|
|
317
341
|
# Computes the full URL to a video asset in the public videos directory.
|
318
342
|
# This will use +video_path+ internally, so most of their behaviors will be the same.
|
343
|
+
# Since +video_url+ is based on +asset_url+ method you can set :host options. If :host
|
344
|
+
# options is set, it overwrites global +config.action_controller.asset_host+ setting.
|
345
|
+
#
|
346
|
+
# video_url "hd.avi", host: "http://stage.example.com" # => http://stage.example.com/hd.avi
|
347
|
+
#
|
319
348
|
def video_url(source, options = {})
|
320
349
|
url_to_asset(source, {type: :video}.merge!(options))
|
321
350
|
end
|
@@ -337,6 +366,11 @@ module ActionView
|
|
337
366
|
|
338
367
|
# Computes the full URL to an audio asset in the public audios directory.
|
339
368
|
# This will use +audio_path+ internally, so most of their behaviors will be the same.
|
369
|
+
# Since +audio_url+ is based on +asset_url+ method you can set :host options. If :host
|
370
|
+
# options is set, it overwrites global +config.action_controller.asset_host+ setting.
|
371
|
+
#
|
372
|
+
# audio_url "horse.wav", host: "http://stage.example.com" # => http://stage.example.com/horse.wav
|
373
|
+
#
|
340
374
|
def audio_url(source, options = {})
|
341
375
|
url_to_asset(source, {type: :audio}.merge!(options))
|
342
376
|
end
|
@@ -357,6 +391,11 @@ module ActionView
|
|
357
391
|
|
358
392
|
# Computes the full URL to a font asset.
|
359
393
|
# This will use +font_path+ internally, so most of their behaviors will be the same.
|
394
|
+
# Since +font_url+ is based on +asset_url+ method you can set :host options. If :host
|
395
|
+
# options is set, it overwrites global +config.action_controller.asset_host+ setting.
|
396
|
+
#
|
397
|
+
# font_url "font.ttf", host: "http://stage.example.com" # => http://stage.example.com/font.ttf
|
398
|
+
#
|
360
399
|
def font_url(source, options = {})
|
361
400
|
url_to_asset(source, {type: :font}.merge!(options))
|
362
401
|
end
|