mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Parse float value only once in number helpers
Refactor number helpers output with safety handling to call float parsing only once. Also remove 'erb' require.
This commit is contained in:
parent
68f23bea6b
commit
ef3e696d1f
1 changed files with 11 additions and 11 deletions
|
@ -5,7 +5,6 @@ require 'active_support/core_ext/object/blank'
|
|||
require 'active_support/core_ext/numeric'
|
||||
require 'active_support/core_ext/string/output_safety'
|
||||
require 'active_support/number_helper'
|
||||
require 'erb'
|
||||
|
||||
module ActionView
|
||||
# = Action View Number Helpers
|
||||
|
@ -408,11 +407,12 @@ module ActionView
|
|||
end
|
||||
|
||||
def wrap_with_output_safety_handling(number, raise_on_invalid, &block)
|
||||
raise InvalidNumberError, number if raise_on_invalid && !valid_float?(number)
|
||||
valid_float = valid_float?(number)
|
||||
raise InvalidNumberError, number if raise_on_invalid && !valid_float
|
||||
|
||||
formatted_number = yield
|
||||
|
||||
if valid_float?(number) || number.html_safe?
|
||||
if valid_float || number.html_safe?
|
||||
formatted_number.html_safe
|
||||
else
|
||||
formatted_number
|
||||
|
|
Loading…
Reference in a new issue