Skip to content

Commit b8964e5

Browse files
authored
Merge pull request rails#45678 from Shopify/action-view-fire-erubi-evaluate
Get rid of Erubi#evaluate
2 parents b712fc9 + 55756ea commit b8964e5

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

actionview/lib/action_view/template/handlers/erb/erubi.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ def initialize(input, properties = {})
2323
super
2424
end
2525

26-
def evaluate(action_view_erb_handler_context)
27-
src = @src
28-
view = Class.new(ActionView::Base) {
29-
include action_view_erb_handler_context._routes.url_helpers
30-
class_eval("define_method(:_template) { |local_assigns, output_buffer| #{src} }", defined?(@filename) ? @filename : "(erubi)", 0)
31-
}.empty
32-
view._run(:_template, nil, {}, ActionView::OutputBuffer.new)
33-
end
34-
3526
private
3627
def add_text(text)
3728
return if text.empty?

actionview/test/template/erb/helper.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@ def protect_against_forgery?() false end
1313
end
1414

1515
class BlockTestCase < ActiveSupport::TestCase
16+
class Context < ActionView::Base
17+
end
18+
1619
def render_content(start, inside, routes = nil)
1720
routes ||= ActionDispatch::Routing::RouteSet.new.tap do |rs|
1821
rs.draw { }
1922
end
20-
context = Class.new(ViewContext) {
21-
include routes.url_helpers
22-
}.new
23-
template = block_helper(start, inside)
24-
ActionView::Template::Handlers::ERB.erb_implementation.new(template).evaluate(context)
23+
24+
view = Class.new(Context)
25+
view.include routes.url_helpers
26+
27+
ActionView::Template.new(
28+
block_helper(start, inside),
29+
"test#{rand}",
30+
ActionView::Template::Handlers::ERB.new,
31+
virtual_path: "partial",
32+
format: :html,
33+
locals: []
34+
).render(view.with_empty_template_cache.empty, {})
2535
end
2636

2737
def block_helper(str, rest)

0 commit comments

Comments
 (0)