1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview
Aaron Patterson 2169bd3d2a
Introduce a file type template, deprecate Template#refresh
Every template that specifies a "virtual path" loses the template source
when the template gets compiled:

  eda0f574f1/actionview/lib/action_view/template.rb (L275)

The "refresh" method seems to think that the source code for a template
can be recovered if there is a virtual path:

  eda0f574f1/actionview/lib/action_view/template.rb (L171-L188)

Every call site that allocates a template object *and* provides a
"virtual path" reads the template contents from the filesystem:

  eda0f574f1/actionview/lib/action_view/template/resolver.rb (L229-L231)

Templates that are inline or literals don't provide a "virtual path":

  eda0f574f1/actionview/lib/action_view/renderer/template_renderer.rb (L34)

This commit introduces a `FileTemplate` type that subclasses `Template`.
The `FileTemplate` keeps a reference to the filename, and reads the
source from the filesystem.  This effectively makes the template source
immutable.

Other classes depended on the source to be mutated while being compiled,
so this commit also introduces a temporary way to pass the mutated
source to the ERB (or whatever) compiler.  See `LegacyTemplate`.

I think we should consider it an error to provide a virtual path on a
non file type template an non-file templates can't recover their source.
Here is an example:

  eda0f574f1/actionview/lib/action_view/testing/resolvers.rb (L53)

This provides a "virtual path" so the source code (a string literal) is
thrown away after compilation.  Clearly we can't recover that string, so
I think this should be an error.
2019-02-01 12:09:46 -08:00
..
app/assets/javascripts Minimize boilerplate setup code for JavaScript libraries 2019-01-16 16:15:43 -05:00
bin Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
lib Introduce a file type template, deprecate Template#refresh 2019-02-01 12:09:46 -08:00
test add tests to make sure deprecated API is still supported 2019-01-31 13:47:13 -08:00
.gitignore Clean up and consolidate .gitignores 2018-02-17 14:26:19 -08:00
actionview.gemspec Revert "Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"" 2019-01-08 22:19:22 +01:00
blade.yml Add rails-ujs to Action View 2016-11-26 01:23:07 -05:00
CHANGELOG.md Add CHANGELOG entries for npm package renames [ci skip] 2019-01-28 06:29:26 -05:00
coffeelint.json Test rails-ujs in our travis matrix 2017-02-22 13:49:28 -05:00
MIT-LICENSE Bump license years for 2019 2018-12-31 10:24:38 +07:00
package.json Preparing for 6.0.0.beta1 release 2019-01-18 15:42:12 -05:00
Rakefile Enable Start/EndWith and RegexpMatch cops 2018-07-28 17:37:17 -04:00
README.rdoc Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
RUNNING_UJS_TESTS.rdoc Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
RUNNING_UNIT_TESTS.rdoc Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00

= Action View

Action View is a framework for handling view template lookup and rendering, and provides
view helpers that assist when building HTML forms, Atom feeds and more.
Template formats that Action View handles are ERB (embedded Ruby, typically
used to inline short Ruby snippets inside HTML), and XML Builder.

== Download and installation

The latest version of Action View can be installed with RubyGems:

  $ gem install actionview

Source code can be downloaded as part of the Rails project on GitHub:

* https://github.com/rails/rails/tree/master/actionview


== License

Action View is released under the MIT license:

* https://opensource.org/licenses/MIT


== Support

API documentation is at

* http://api.rubyonrails.org

Bug reports for the Ruby on Rails project can be filed here:

* https://github.com/rails/rails/issues

Feature requests should be discussed on the rails-core mailing list here:

* https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core