actionview 4.2.0.beta1 → 4.2.0.beta2
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 +4 -4
- data/CHANGELOG.md +35 -7
- data/lib/action_view/base.rb +7 -3
- data/lib/action_view/buffers.rb +4 -3
- data/lib/action_view/gem_version.rb +2 -2
- data/lib/action_view/helpers/asset_url_helper.rb +1 -1
- data/lib/action_view/helpers/form_helper.rb +5 -13
- data/lib/action_view/helpers/form_tag_helper.rb +1 -1
- data/lib/action_view/helpers/sanitize_helper.rb +13 -30
- data/lib/action_view/helpers/tag_helper.rb +6 -4
- data/lib/action_view/helpers/tags/label.rb +46 -22
- data/lib/action_view/helpers/tags/placeholderable.rb +3 -1
- data/lib/action_view/helpers/translation_helper.rb +1 -0
- data/lib/action_view/helpers/url_helper.rb +14 -22
- data/lib/action_view/rendering.rb +2 -2
- data/lib/action_view/template.rb +4 -14
- data/lib/action_view/template/handlers/erb.rb +2 -2
- data/lib/action_view/test_case.rb +1 -2
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d4d2a57740f13583c986df13dac46c2069c0af3
|
4
|
+
data.tar.gz: fff03848a3d649b989f320801f19b4ac577bd757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 391dc5022503c4265798133411e35d9893195a3043bb807c95c90da3cab23c404208d4ec54df967585cdcc651f53f5f2f2199e9af079530df39b3921c7ea00df
|
7
|
+
data.tar.gz: 0e896661e58b9a1ac325900ff3271f117ee514b1228f9d73fa71d0c56823b76a54f8ef4e8583c2b1a4e7b0e0131a057384ffd1a0d44931d5418b1db68b7a62cd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
* Changed the meaning of `render "foo/bar"`.
|
2
|
+
|
3
|
+
Previously, calling `render "foo/bar"` in a controller action is equivalent
|
4
|
+
to `render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
|
5
|
+
`render template: "foo/bar"` instead. If you need to render a file, please
|
6
|
+
change your code to use the explicit form (`render file: "foo/bar"`) instead.
|
7
|
+
|
8
|
+
*Jeremy Jackson*
|
9
|
+
|
10
|
+
* Add support for ARIA attributes in tags.
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
<%= f.text_field :name, aria: { required: "true", hidden: "false" } %>
|
15
|
+
|
16
|
+
now generates:
|
17
|
+
|
18
|
+
<input aria-hidden="false" aria-required="true" id="user_name" name="user[name]" type="text">
|
19
|
+
|
20
|
+
*Paola Garcia Casadiego*
|
21
|
+
|
22
|
+
* Provide a `builder` object when using the `label` form helper in block form.
|
23
|
+
|
24
|
+
The new `builder` object responds to `translation`, allowing I18n fallback support
|
25
|
+
when you want to customize how a particular label is presented.
|
26
|
+
|
27
|
+
*Alex Robbin*
|
28
|
+
|
1
29
|
* Add I18n support for input/textarea placeholder text.
|
2
30
|
|
3
31
|
Placeholder I18n follows the same convention as `label` I18n.
|
@@ -19,11 +47,11 @@
|
|
19
47
|
*Joel Junström*, *Lucas Uyezu*
|
20
48
|
|
21
49
|
* Return an absolute instead of relative path from an asset url in the case
|
22
|
-
of the `asset_host` proc returning nil
|
50
|
+
of the `asset_host` proc returning nil.
|
23
51
|
|
24
52
|
*Jolyon Pawlyn*
|
25
53
|
|
26
|
-
* Fix `html_escape_once` to properly handle hex escape sequences (e.g. ᨫ)
|
54
|
+
* Fix `html_escape_once` to properly handle hex escape sequences (e.g. ᨫ).
|
27
55
|
|
28
56
|
*John F. Douthat*
|
29
57
|
|
@@ -56,7 +84,7 @@
|
|
56
84
|
|
57
85
|
*Zuhao Wan*
|
58
86
|
|
59
|
-
* Bring `cache_digest` rake tasks up-to-date with the latest API changes
|
87
|
+
* Bring `cache_digest` rake tasks up-to-date with the latest API changes.
|
60
88
|
|
61
89
|
*Jiri Pospisil*
|
62
90
|
|
@@ -108,12 +136,12 @@
|
|
108
136
|
|
109
137
|
Before:
|
110
138
|
|
111
|
-
|
139
|
+
# => favicon_link_tag 'myicon.ico'
|
112
140
|
<link href="/assets/myicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
|
113
141
|
|
114
142
|
After:
|
115
143
|
|
116
|
-
|
144
|
+
# => favicon_link_tag 'myicon.ico'
|
117
145
|
<link href="/assets/myicon.ico" rel="shortcut icon" type="image/x-icon" />
|
118
146
|
|
119
147
|
*Geoffroy Lorieux*
|
@@ -126,7 +154,7 @@
|
|
126
154
|
|
127
155
|
*Joost Baaij*
|
128
156
|
|
129
|
-
* `collection_check_boxes` respects `:index` option for the hidden
|
157
|
+
* `collection_check_boxes` respects `:index` option for the hidden field name.
|
130
158
|
|
131
159
|
Fixes #14147.
|
132
160
|
|
@@ -147,7 +175,7 @@
|
|
147
175
|
|
148
176
|
*Vasiliy Ermolovich*
|
149
177
|
|
150
|
-
* Fixed a problem where the default options for the `button_tag` helper
|
178
|
+
* Fixed a problem where the default options for the `button_tag` helper are not
|
151
179
|
applied correctly.
|
152
180
|
|
153
181
|
Fixes #14254.
|
data/lib/action_view/base.rb
CHANGED
@@ -10,8 +10,10 @@ require 'action_view/lookup_context'
|
|
10
10
|
module ActionView #:nodoc:
|
11
11
|
# = Action View Base
|
12
12
|
#
|
13
|
-
# Action View templates can be written in several ways.
|
14
|
-
#
|
13
|
+
# Action View templates can be written in several ways.
|
14
|
+
# If the template file has a <tt>.erb</tt> extension, then it uses the erubis[https://rubygems.org/gems/erubis]
|
15
|
+
# template system which can embed Ruby into an HTML document.
|
16
|
+
# If the template file has a <tt>.builder</tt> extension, then Jim Weirich's Builder::XmlMarkup library is used.
|
15
17
|
#
|
16
18
|
# == ERB
|
17
19
|
#
|
@@ -31,7 +33,9 @@ module ActionView #:nodoc:
|
|
31
33
|
#
|
32
34
|
# If you absolutely must write from within a function use +concat+.
|
33
35
|
#
|
34
|
-
#
|
36
|
+
# When on a line that only contains whitespaces except for the tag, <% %> suppress leading and trailing whitespace,
|
37
|
+
# including the trailing newline. <% %> and <%- -%> are the same.
|
38
|
+
# Note however that <%= %> and <%= -%> are different: only the latter removes trailing whitespaces.
|
35
39
|
#
|
36
40
|
# === Using sub templates
|
37
41
|
#
|
data/lib/action_view/buffers.rb
CHANGED
@@ -13,10 +13,11 @@ module ActionView
|
|
13
13
|
end
|
14
14
|
alias :append= :<<
|
15
15
|
|
16
|
-
def
|
17
|
-
return self if
|
18
|
-
|
16
|
+
def safe_expr_append=(val)
|
17
|
+
return self if val.nil?
|
18
|
+
safe_concat val.to_s
|
19
19
|
end
|
20
|
+
|
20
21
|
alias :safe_append= :safe_concat
|
21
22
|
end
|
22
23
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ActionView
|
2
|
-
# Returns the version of the currently loaded
|
2
|
+
# Returns the version of the currently loaded Action View as a <tt>Gem::Version</tt>
|
3
3
|
def self.gem_version
|
4
4
|
Gem::Version.new VERSION::STRING
|
5
5
|
end
|
@@ -8,7 +8,7 @@ module ActionView
|
|
8
8
|
MAJOR = 4
|
9
9
|
MINOR = 2
|
10
10
|
TINY = 0
|
11
|
-
PRE = "
|
11
|
+
PRE = "beta2"
|
12
12
|
|
13
13
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
14
14
|
end
|
@@ -121,8 +121,8 @@ module ActionView
|
|
121
121
|
# asset_path "application", type: :stylesheet # => /assets/application.css
|
122
122
|
# asset_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
|
123
123
|
def asset_path(source, options = {})
|
124
|
-
return "" unless source.present?
|
125
124
|
source = source.to_s
|
125
|
+
return "" unless source.present?
|
126
126
|
return source if source =~ URI_REGEXP
|
127
127
|
|
128
128
|
tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, '')
|
@@ -51,9 +51,7 @@ module ActionView
|
|
51
51
|
# The HTML generated for this would be (modulus formatting):
|
52
52
|
#
|
53
53
|
# <form action="/people" class="new_person" id="new_person" method="post">
|
54
|
-
# <
|
55
|
-
# <input name="authenticity_token" type="hidden" value="NrOp5bsjoLRuK8IW5+dQEYjKGUJDe7TQoZVvq95Wteg=" />
|
56
|
-
# </div>
|
54
|
+
# <input name="authenticity_token" type="hidden" value="NrOp5bsjoLRuK8IW5+dQEYjKGUJDe7TQoZVvq95Wteg=" />
|
57
55
|
# <label for="person_first_name">First name</label>:
|
58
56
|
# <input id="person_first_name" name="person[first_name]" type="text" /><br />
|
59
57
|
#
|
@@ -81,10 +79,8 @@ module ActionView
|
|
81
79
|
# the code above as is would yield instead:
|
82
80
|
#
|
83
81
|
# <form action="/people/256" class="edit_person" id="edit_person_256" method="post">
|
84
|
-
# <
|
85
|
-
#
|
86
|
-
# <input name="authenticity_token" type="hidden" value="NrOp5bsjoLRuK8IW5+dQEYjKGUJDe7TQoZVvq95Wteg=" />
|
87
|
-
# </div>
|
82
|
+
# <input name="_method" type="hidden" value="patch" />
|
83
|
+
# <input name="authenticity_token" type="hidden" value="NrOp5bsjoLRuK8IW5+dQEYjKGUJDe7TQoZVvq95Wteg=" />
|
88
84
|
# <label for="person_first_name">First name</label>:
|
89
85
|
# <input id="person_first_name" name="person[first_name]" type="text" value="John" /><br />
|
90
86
|
#
|
@@ -315,9 +311,7 @@ module ActionView
|
|
315
311
|
# The HTML generated for this would be:
|
316
312
|
#
|
317
313
|
# <form action='http://www.example.com' method='post' data-remote='true'>
|
318
|
-
# <
|
319
|
-
# <input name='_method' type='hidden' value='patch' />
|
320
|
-
# </div>
|
314
|
+
# <input name='_method' type='hidden' value='patch' />
|
321
315
|
# ...
|
322
316
|
# </form>
|
323
317
|
#
|
@@ -333,9 +327,7 @@ module ActionView
|
|
333
327
|
# The HTML generated for this would be:
|
334
328
|
#
|
335
329
|
# <form action='http://www.example.com' method='post' data-behavior='autosave' name='go'>
|
336
|
-
# <
|
337
|
-
# <input name='_method' type='hidden' value='patch' />
|
338
|
-
# </div>
|
330
|
+
# <input name='_method' type='hidden' value='patch' />
|
339
331
|
# ...
|
340
332
|
# </form>
|
341
333
|
#
|
@@ -35,10 +35,10 @@ module ActionView
|
|
35
35
|
# This is helpful when you're fragment-caching the form. Remote forms get the
|
36
36
|
# authenticity token from the <tt>meta</tt> tag, so embedding is unnecessary unless you
|
37
37
|
# support browsers without JavaScript.
|
38
|
-
# * A list of parameters to feed to the URL the form will be posted to.
|
39
38
|
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
|
40
39
|
# submit behavior. By default this behavior is an ajax submit.
|
41
40
|
# * <tt>:enforce_utf8</tt> - If set to false, a hidden input with name utf8 is not output.
|
41
|
+
# * Any other key creates standard HTML attributes for the tag.
|
42
42
|
#
|
43
43
|
# ==== Examples
|
44
44
|
# form_tag('/posts')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext/object/try'
|
2
2
|
require 'active_support/deprecation'
|
3
|
-
require 'rails-
|
3
|
+
require 'rails-html-sanitizer'
|
4
4
|
|
5
5
|
module ActionView
|
6
6
|
# = Action View Sanitize Helpers
|
@@ -121,31 +121,10 @@ module ActionView
|
|
121
121
|
module ClassMethods #:nodoc:
|
122
122
|
attr_writer :full_sanitizer, :link_sanitizer, :white_list_sanitizer
|
123
123
|
|
124
|
-
[:protocol_separator,
|
125
|
-
:uri_attributes,
|
126
|
-
:bad_tags,
|
127
|
-
:allowed_css_properties,
|
128
|
-
:allowed_css_keywords,
|
129
|
-
:shorthand_css_properties,
|
130
|
-
:allowed_protocols].each do |meth|
|
131
|
-
meth_name = "sanitized_#{meth}"
|
132
|
-
imp = lambda do |name|
|
133
|
-
ActiveSupport::Deprecation.warn("#{name} is deprecated and has no effect.")
|
134
|
-
end
|
135
|
-
|
136
|
-
define_method(meth_name) { imp.(meth_name) }
|
137
|
-
define_method("#{meth_name}=") { |value| imp.("#{meth_name}=") }
|
138
|
-
end
|
139
|
-
|
140
124
|
# Vendors the full, link and white list sanitizers.
|
141
|
-
#
|
142
|
-
# In the next Rails version this will use Rails::Html::Sanitizer instead.
|
143
|
-
# To get this new behavior now, in your Gemfile, add:
|
144
|
-
#
|
145
|
-
# gem 'rails-html-sanitizer'
|
146
|
-
#
|
125
|
+
# Provided strictly for compabitility and can be removed in Rails 5.
|
147
126
|
def sanitizer_vendor
|
148
|
-
Rails::
|
127
|
+
Rails::Html::Sanitizer
|
149
128
|
end
|
150
129
|
|
151
130
|
def sanitized_allowed_tags
|
@@ -189,25 +168,29 @@ module ActionView
|
|
189
168
|
@white_list_sanitizer ||= sanitizer_vendor.white_list_sanitizer.new
|
190
169
|
end
|
191
170
|
|
171
|
+
##
|
172
|
+
# :method: sanitized_allowed_tags=
|
173
|
+
#
|
174
|
+
# :call-seq: sanitized_allowed_tags=(tags)
|
175
|
+
#
|
192
176
|
# Replaces the allowed tags for the +sanitize+ helper.
|
193
177
|
#
|
194
178
|
# class Application < Rails::Application
|
195
179
|
# config.action_view.sanitized_allowed_tags = 'table', 'tr', 'td'
|
196
180
|
# end
|
197
181
|
#
|
198
|
-
def sanitized_allowed_tags=(tags)
|
199
|
-
sanitizer_vendor.white_list_sanitizer.allowed_tags = tags
|
200
|
-
end
|
201
182
|
|
183
|
+
##
|
184
|
+
# :method: sanitized_allowed_attributes=
|
185
|
+
#
|
186
|
+
# :call-seq: sanitized_allowed_attributes=(attributes)
|
187
|
+
#
|
202
188
|
# Replaces the allowed HTML attributes for the +sanitize+ helper.
|
203
189
|
#
|
204
190
|
# class Application < Rails::Application
|
205
191
|
# config.action_view.sanitized_allowed_attributes = ['onclick', 'longdesc']
|
206
192
|
# end
|
207
193
|
#
|
208
|
-
def sanitized_allowed_attributes=(attributes)
|
209
|
-
sanitizer_vendor.white_list_sanitizer.allowed_attributes = attributes
|
210
|
-
end
|
211
194
|
end
|
212
195
|
end
|
213
196
|
end
|
@@ -20,6 +20,8 @@ module ActionView
|
|
20
20
|
|
21
21
|
BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map {|attribute| attribute.to_sym })
|
22
22
|
|
23
|
+
TAG_PREFIXES = ['aria', 'data', :aria, :data].to_set
|
24
|
+
|
23
25
|
PRE_CONTENT_STRINGS = {
|
24
26
|
:textarea => "\n"
|
25
27
|
}
|
@@ -148,9 +150,9 @@ module ActionView
|
|
148
150
|
return if options.blank?
|
149
151
|
attrs = []
|
150
152
|
options.each_pair do |key, value|
|
151
|
-
if key
|
153
|
+
if TAG_PREFIXES.include?(key) && value.is_a?(Hash)
|
152
154
|
value.each_pair do |k, v|
|
153
|
-
attrs <<
|
155
|
+
attrs << prefix_tag_option(key, k, v, escape)
|
154
156
|
end
|
155
157
|
elsif BOOLEAN_ATTRIBUTES.include?(key)
|
156
158
|
attrs << boolean_tag_option(key) if value
|
@@ -161,8 +163,8 @@ module ActionView
|
|
161
163
|
" #{attrs.sort! * ' '}" unless attrs.empty?
|
162
164
|
end
|
163
165
|
|
164
|
-
def
|
165
|
-
key
|
166
|
+
def prefix_tag_option(prefix, key, value, escape)
|
167
|
+
key = "#{prefix}-#{key.to_s.dasherize}"
|
166
168
|
unless value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(BigDecimal)
|
167
169
|
value = value.to_json
|
168
170
|
end
|
@@ -2,6 +2,39 @@ module ActionView
|
|
2
2
|
module Helpers
|
3
3
|
module Tags # :nodoc:
|
4
4
|
class Label < Base # :nodoc:
|
5
|
+
class LabelBuilder # :nodoc:
|
6
|
+
attr_reader :object
|
7
|
+
|
8
|
+
def initialize(template_object, object_name, method_name, object, tag_value)
|
9
|
+
@template_object = template_object
|
10
|
+
@object_name = object_name
|
11
|
+
@method_name = method_name
|
12
|
+
@object = object
|
13
|
+
@tag_value = tag_value
|
14
|
+
end
|
15
|
+
|
16
|
+
def translation
|
17
|
+
method_and_value = @tag_value.present? ? "#{@method_name}.#{@tag_value}" : @method_name
|
18
|
+
@object_name.gsub!(/\[(.*)_attributes\]\[\d+\]/, '.\1')
|
19
|
+
|
20
|
+
if object.respond_to?(:to_model)
|
21
|
+
key = object.model_name.i18n_key
|
22
|
+
i18n_default = ["#{key}.#{method_and_value}".to_sym, ""]
|
23
|
+
end
|
24
|
+
|
25
|
+
i18n_default ||= ""
|
26
|
+
content = I18n.t("#{@object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.label").presence
|
27
|
+
|
28
|
+
content ||= if object && object.class.respond_to?(:human_attribute_name)
|
29
|
+
object.class.human_attribute_name(method_and_value)
|
30
|
+
end
|
31
|
+
|
32
|
+
content ||= @method_name.humanize
|
33
|
+
|
34
|
+
content
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
5
38
|
def initialize(object_name, method_name, template_object, content_or_options = nil, options = nil)
|
6
39
|
options ||= {}
|
7
40
|
|
@@ -32,33 +65,24 @@ module ActionView
|
|
32
65
|
options.delete("namespace")
|
33
66
|
options["for"] = name_and_id["id"] unless options.key?("for")
|
34
67
|
|
35
|
-
|
36
|
-
content = @template_object.capture(&block)
|
37
|
-
else
|
38
|
-
method_and_value = tag_value.present? ? "#{@method_name}.#{tag_value}" : @method_name
|
39
|
-
content = if @content.blank?
|
40
|
-
@object_name.gsub!(/\[(.*)_attributes\]\[\d+\]/, '.\1')
|
41
|
-
|
42
|
-
if object.respond_to?(:to_model)
|
43
|
-
key = object.model_name.i18n_key
|
44
|
-
i18n_default = ["#{key}.#{method_and_value}".to_sym, ""]
|
45
|
-
end
|
46
|
-
|
47
|
-
i18n_default ||= ""
|
48
|
-
I18n.t("#{@object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.label").presence
|
49
|
-
else
|
50
|
-
@content.to_s
|
51
|
-
end
|
52
|
-
|
53
|
-
content ||= if object && object.class.respond_to?(:human_attribute_name)
|
54
|
-
object.class.human_attribute_name(method_and_value)
|
55
|
-
end
|
68
|
+
builder = LabelBuilder.new(@template_object, @object_name, @method_name, @object, tag_value)
|
56
69
|
|
57
|
-
|
70
|
+
content = if block_given?
|
71
|
+
@template_object.capture(builder, &block)
|
72
|
+
elsif @content.present?
|
73
|
+
@content.to_s
|
74
|
+
else
|
75
|
+
render_component(builder)
|
58
76
|
end
|
59
77
|
|
60
78
|
label_tag(name_and_id["id"], content, options)
|
61
79
|
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def render_component(builder)
|
84
|
+
builder.translation
|
85
|
+
end
|
62
86
|
end
|
63
87
|
end
|
64
88
|
end
|
@@ -6,6 +6,8 @@ module ActionView
|
|
6
6
|
super
|
7
7
|
|
8
8
|
if tag_value = @options[:placeholder]
|
9
|
+
placeholder = tag_value if tag_value.is_a?(String)
|
10
|
+
|
9
11
|
object_name = @object_name.gsub(/\[(.*)_attributes\]\[\d+\]/, '.\1')
|
10
12
|
method_and_value = tag_value.is_a?(TrueClass) ? @method_name : "#{@method_name}.#{tag_value}"
|
11
13
|
|
@@ -15,7 +17,7 @@ module ActionView
|
|
15
17
|
end
|
16
18
|
|
17
19
|
i18n_default ||= ""
|
18
|
-
placeholder
|
20
|
+
placeholder ||= I18n.t("#{object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.placeholder").presence
|
19
21
|
|
20
22
|
placeholder ||= if object && object.class.respond_to?(:human_attribute_name)
|
21
23
|
object.class.human_attribute_name(method_and_value)
|
@@ -6,6 +6,7 @@ module ActionView
|
|
6
6
|
# = Action View Translation Helpers
|
7
7
|
module Helpers
|
8
8
|
module TranslationHelper
|
9
|
+
include TagHelper
|
9
10
|
# Delegates to <tt>I18n#translate</tt> but also performs three additional functions.
|
10
11
|
#
|
11
12
|
# First, it will ensure that any thrown +MissingTranslation+ messages will be turned
|
@@ -229,59 +229,51 @@ module ActionView
|
|
229
229
|
# ==== Examples
|
230
230
|
# <%= button_to "New", action: "new" %>
|
231
231
|
# # => "<form method="post" action="/controller/new" class="button_to">
|
232
|
-
# # <
|
232
|
+
# # <input value="New" type="submit" />
|
233
233
|
# # </form>"
|
234
234
|
#
|
235
235
|
# <%= button_to "New", new_articles_path %>
|
236
236
|
# # => "<form method="post" action="/articles/new" class="button_to">
|
237
|
-
# # <
|
237
|
+
# # <input value="New" type="submit" />
|
238
238
|
# # </form>"
|
239
239
|
#
|
240
240
|
# <%= button_to [:make_happy, @user] do %>
|
241
241
|
# Make happy <strong><%= @user.name %></strong>
|
242
242
|
# <% end %>
|
243
243
|
# # => "<form method="post" action="/users/1/make_happy" class="button_to">
|
244
|
-
# # <
|
245
|
-
# # <
|
246
|
-
# #
|
247
|
-
# # </button>
|
248
|
-
# # </div>
|
244
|
+
# # <button type="submit">
|
245
|
+
# # Make happy <strong><%= @user.name %></strong>
|
246
|
+
# # </button>
|
249
247
|
# # </form>"
|
250
248
|
#
|
251
249
|
# <%= button_to "New", { action: "new" }, form_class: "new-thing" %>
|
252
250
|
# # => "<form method="post" action="/controller/new" class="new-thing">
|
253
|
-
# # <
|
251
|
+
# # <input value="New" type="submit" />
|
254
252
|
# # </form>"
|
255
253
|
#
|
256
254
|
#
|
257
255
|
# <%= button_to "Create", { action: "create" }, remote: true, form: { "data-type" => "json" } %>
|
258
256
|
# # => "<form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
|
259
|
-
# # <
|
260
|
-
# #
|
261
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
262
|
-
# # </div>
|
257
|
+
# # <input value="Create" type="submit" />
|
258
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
263
259
|
# # </form>"
|
264
260
|
#
|
265
261
|
#
|
266
262
|
# <%= button_to "Delete Image", { action: "delete", id: @image.id },
|
267
263
|
# method: :delete, data: { confirm: "Are you sure?" } %>
|
268
264
|
# # => "<form method="post" action="/images/delete/1" class="button_to">
|
269
|
-
# # <
|
270
|
-
# #
|
271
|
-
# #
|
272
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
273
|
-
# # </div>
|
265
|
+
# # <input type="hidden" name="_method" value="delete" />
|
266
|
+
# # <input data-confirm='Are you sure?' value="Delete Image" type="submit" />
|
267
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
274
268
|
# # </form>"
|
275
269
|
#
|
276
270
|
#
|
277
271
|
# <%= button_to('Destroy', 'http://www.example.com',
|
278
272
|
# method: "delete", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %>
|
279
273
|
# # => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>
|
280
|
-
# # <
|
281
|
-
# #
|
282
|
-
# #
|
283
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
284
|
-
# # </div>
|
274
|
+
# # <input name='_method' value='delete' type='hidden' />
|
275
|
+
# # <input value='Destroy' type='submit' data-disable-with='loading...' data-confirm='Are you sure?' />
|
276
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
285
277
|
# # </form>"
|
286
278
|
# #
|
287
279
|
def button_to(name = nil, options = nil, html_options = nil, &block)
|
@@ -108,7 +108,7 @@ module ActionView
|
|
108
108
|
end
|
109
109
|
|
110
110
|
# Normalize args by converting render "foo" to render :action => "foo" and
|
111
|
-
# render "foo/bar" to render :
|
111
|
+
# render "foo/bar" to render :template => "foo/bar".
|
112
112
|
# :api: private
|
113
113
|
def _normalize_args(action=nil, options={})
|
114
114
|
options = super(action, options)
|
@@ -118,7 +118,7 @@ module ActionView
|
|
118
118
|
options = action
|
119
119
|
when String, Symbol
|
120
120
|
action = action.to_s
|
121
|
-
key = action.include?(?/) ? :
|
121
|
+
key = action.include?(?/) ? :template : :action
|
122
122
|
options[key] = action
|
123
123
|
else
|
124
124
|
options[:partial] = action
|
data/lib/action_view/template.rb
CHANGED
@@ -242,7 +242,7 @@ module ActionView
|
|
242
242
|
end
|
243
243
|
|
244
244
|
instrument("!compile_template") do
|
245
|
-
compile(
|
245
|
+
compile(mod)
|
246
246
|
end
|
247
247
|
|
248
248
|
# Just discard the source if we have a virtual path. This
|
@@ -264,7 +264,7 @@ module ActionView
|
|
264
264
|
# encode the source into <tt>Encoding.default_internal</tt>.
|
265
265
|
# In general, this means that templates will be UTF-8 inside of Rails,
|
266
266
|
# regardless of the original source encoding.
|
267
|
-
def compile(
|
267
|
+
def compile(mod) #:nodoc:
|
268
268
|
encode!
|
269
269
|
method_name = self.method_name
|
270
270
|
code = @handler.call(self)
|
@@ -293,18 +293,8 @@ module ActionView
|
|
293
293
|
raise WrongEncodingError.new(@source, Encoding.default_internal)
|
294
294
|
end
|
295
295
|
|
296
|
-
|
297
|
-
|
298
|
-
ObjectSpace.define_finalizer(self, Finalizer[method_name, mod])
|
299
|
-
rescue => e # errors from template code
|
300
|
-
if logger = (view && view.logger)
|
301
|
-
logger.debug "ERROR: compiling #{method_name} RAISED #{e}"
|
302
|
-
logger.debug "Function body: #{source}"
|
303
|
-
logger.debug "Backtrace: #{e.backtrace.join("\n")}"
|
304
|
-
end
|
305
|
-
|
306
|
-
raise ActionView::Template::Error.new(self, e)
|
307
|
-
end
|
296
|
+
mod.module_eval(source, identifier, 0)
|
297
|
+
ObjectSpace.define_finalizer(self, Finalizer[method_name, mod])
|
308
298
|
end
|
309
299
|
|
310
300
|
def handle_render_error(view, e) #:nodoc:
|
@@ -49,9 +49,9 @@ module ActionView
|
|
49
49
|
def add_expr_escaped(src, code)
|
50
50
|
flush_newline_if_pending(src)
|
51
51
|
if code =~ BLOCK_EXPR
|
52
|
-
src << "@output_buffer.
|
52
|
+
src << "@output_buffer.safe_expr_append= " << code
|
53
53
|
else
|
54
|
-
src << "@output_buffer.
|
54
|
+
src << "@output_buffer.safe_expr_append=(" << code << ");"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -158,8 +158,7 @@ module ActionView
|
|
158
158
|
|
159
159
|
# Need to experiment if this priority is the best one: rendered => output_buffer
|
160
160
|
def document_root_element
|
161
|
-
|
162
|
-
@html_document.root
|
161
|
+
Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered).root
|
163
162
|
end
|
164
163
|
|
165
164
|
def say_no_to_protect_against_forgery!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.0.
|
4
|
+
version: 4.2.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.2.0.
|
19
|
+
version: 4.2.0.beta2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.2.0.
|
26
|
+
version: 4.2.0.beta2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.7.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: rails-
|
56
|
+
name: rails-html-sanitizer
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '1.0'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 1.0.
|
64
|
+
version: 1.0.1
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: '1.0'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.0.
|
74
|
+
version: 1.0.1
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rails-dom-testing
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
version: '1.0'
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 1.0.
|
84
|
+
version: 1.0.3
|
85
85
|
type: :runtime
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,35 +91,35 @@ dependencies:
|
|
91
91
|
version: '1.0'
|
92
92
|
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 1.0.
|
94
|
+
version: 1.0.3
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: actionpack
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - '='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 4.2.0.
|
101
|
+
version: 4.2.0.beta2
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - '='
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: 4.2.0.
|
108
|
+
version: 4.2.0.beta2
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: activemodel
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - '='
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: 4.2.0.
|
115
|
+
version: 4.2.0.beta2
|
116
116
|
type: :development
|
117
117
|
prerelease: false
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - '='
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 4.2.0.
|
122
|
+
version: 4.2.0.beta2
|
123
123
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
124
124
|
email: david@loudthinking.com
|
125
125
|
executables: []
|