1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove deprecated Erubis ERB handler

This commit is contained in:
Rafael Mendonça França 2017-07-17 16:45:59 -04:00
parent 40cadf52db
commit 7de7f12fd1
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
7 changed files with 4 additions and 117 deletions

View file

@ -51,9 +51,6 @@ gem "dalli", ">= 2.2.1"
gem "listen", ">= 3.0.5", "< 3.2", require: false
gem "libxml-ruby", platforms: :ruby
# Action View. For testing Erubis handler deprecation.
gem "erubis", "~> 2.7.0", require: false
# for railties app_generator_test
gem "bootsnap", ">= 1.1.0", require: false

View file

@ -253,7 +253,6 @@ GEM
em-socksify (0.3.1)
eventmachine (>= 1.0.0.beta.4)
erubi (1.6.1)
erubis (2.7.0)
et-orbi (1.0.5)
tzinfo
event_emitter (0.2.6)
@ -540,7 +539,6 @@ DEPENDENCIES
delayed_job
delayed_job_active_record
em-hiredis
erubis (~> 2.7.0)
google-cloud-storage (~> 1.3)
hiredis
json (>= 2.0.0)

View file

@ -1,3 +1,7 @@
* Remove deprecated Erubis ERB handler.
*Rafael Mendonça França*
* Remove default `alt` text generation.
Fixes #30096

View file

@ -3,11 +3,8 @@
module ActionView
class Template
module Handlers
autoload :Erubis, "action_view/template/handlers/erb/deprecated_erubis"
class ERB
autoload :Erubi, "action_view/template/handlers/erb/erubi"
autoload :Erubis, "action_view/template/handlers/erb/erubis"
# Specify trim mode for the ERB compiler. Defaults to '-'.
# See ERB documentation for suitable values.

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
::ActiveSupport::Deprecation.warn("ActionView::Template::Handlers::Erubis is deprecated and will be removed from Rails 5.2. Switch to ActionView::Template::Handlers::ERB::Erubi instead.")
module ActionView
class Template
module Handlers
Erubis = ERB::Erubis
end
end
end

View file

@ -1,83 +0,0 @@
# frozen_string_literal: true
gem "erubis"
require "erubis"
module ActionView
class Template
module Handlers
class ERB
class Erubis < ::Erubis::Eruby
# :nodoc: all
def add_preamble(src)
@newline_pending = 0
src << "@output_buffer = output_buffer || ActionView::OutputBuffer.new;"
end
def add_text(src, text)
return if text.empty?
if text == "\n"
@newline_pending += 1
else
src << "@output_buffer.safe_append='"
src << "\n" * @newline_pending if @newline_pending > 0
src << escape_text(text)
src << "'.freeze;"
@newline_pending = 0
end
end
# Erubis toggles <%= and <%== behavior when escaping is enabled.
# We override to always treat <%== as escaped.
def add_expr(src, code, indicator)
case indicator
when "=="
add_expr_escaped(src, code)
else
super
end
end
BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/
def add_expr_literal(src, code)
flush_newline_if_pending(src)
if BLOCK_EXPR.match?(code)
src << "@output_buffer.append= " << code
else
src << "@output_buffer.append=(" << code << ");"
end
end
def add_expr_escaped(src, code)
flush_newline_if_pending(src)
if BLOCK_EXPR.match?(code)
src << "@output_buffer.safe_expr_append= " << code
else
src << "@output_buffer.safe_expr_append=(" << code << ");"
end
end
def add_stmt(src, code)
flush_newline_if_pending(src)
super
end
def add_postamble(src)
flush_newline_if_pending(src)
src << "@output_buffer.to_s"
end
def flush_newline_if_pending(src)
if @newline_pending > 0
src << "@output_buffer.safe_append='#{"\n" * @newline_pending}'.freeze;"
@newline_pending = 0
end
end
end
end
end
end
end

View file

@ -1,15 +0,0 @@
# frozen_string_literal: true
require "abstract_unit"
module ERBTest
class DeprecatedErubisImplementationTest < ActionView::TestCase
test "Erubis implementation is deprecated" do
assert_deprecated "ActionView::Template::Handlers::Erubis is deprecated and will be removed from Rails 5.2. Switch to ActionView::Template::Handlers::ERB::Erubi instead." do
assert_equal "ActionView::Template::Handlers::ERB::Erubis", ActionView::Template::Handlers::Erubis.to_s
assert_nothing_raised { Class.new(ActionView::Template::Handlers::Erubis) }
end
end
end
end