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

Don't discard source after rendering

Previously, we would discard the template source after rendering, if we
had a virtual path, in hopes that the virtual path would let us find our
same template again going through the Resolver.

Previously we discarded the source as an optimization, to avoid keeping
it around in memory. By instead just reading the file every time source
is called, as FileTemplate does, this is unnecessary.
This commit is contained in:
John Hawthorn 2019-04-04 12:42:57 -07:00
parent a8aca02350
commit b8c90c3644
2 changed files with 2 additions and 5 deletions

View file

@ -298,9 +298,6 @@ module ActionView
compile(mod)
end
# Just discard the source if we have a virtual path. This
# means we can get the template back.
@source = nil if @virtual_path
@compiled = true
end
end

View file

@ -91,10 +91,10 @@ class TestERBTemplate < ActiveSupport::TestCase
assert_equal "<%= hello %>", render
end
def test_template_loses_its_source_after_rendering
def test_template_does_not_lose_its_source_after_rendering
@template = new_template
render
assert_nil @template.source
assert_equal "<%= hello %>", @template.source
end
def test_template_does_not_lose_its_source_after_rendering_if_it_does_not_have_a_virtual_path