aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view.rb
Commit message (Collapse)AuthorAgeFilesLines
* Autoload SyntaxErrorInTemplateGuilherme Mansur2019-06-191-0/+1
| | | | | | | | | | | | When a SyntaxError is detected in a template we raise this exception. On a first request to the server the exception we get a NameError since the exception is not required from `active_view/template/error.rb` yet. However later on it gets required and a second request will succeed. On the first request we see the rails "Something Wen Wrong" page and not the expected syntax error in template error page with the webconsole and stacktrace. By autoloading the constant we fix this issue. Co-authored-by: Gannon McGibbon <gannon.mcgibbon@gmail.com>
* De-dup Templates, introduce UnboundTemplateJohn Hawthorn2019-04-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | Previously it's possible to have multiple copies of the "same" Template. For example, if index.html.erb is found both the :en and :fr locale, it will return a different Template object for each. The same can happen with formats, variants, and handlers. This commit de-duplicates templates, there will now only be one template per file/virtual_path/locals tuple. We need to consider virtual_path because both `render "index"`, and `render "index.html"` can both find the same file but will have different virtual_paths. IMO this is rare and should be deprecated/removed, but it exists now so we need to consider it in order to cache correctly. This commit introduces a new UnboundTemplate class, which represents a template with unknown locals. Template objects can be built from it by using `#with_locals`. Currently, this is just a convenience around caching templates, but I hope it's a helpful concept that could have more utility in the future.
* Remove FileTemplateJohn Hawthorn2019-04-041-1/+0
| | | | This is unnecessary now that we can just provide a file source
* Only clear template caches in dev after changes (#35629)John Hawthorn2019-04-011-0/+1
|
* Move templates to an anonymous subclass of AV::BaseAaron Patterson2019-02-061-1/+0
| | | | | Now we can throw away the subclass and the generated methods will get GC'd too
* Introduce a file type template, deprecate `Template#refresh`Aaron Patterson2019-02-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Every template that specifies a "virtual path" loses the template source when the template gets compiled: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/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: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/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: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/actionview/lib/action_view/template/resolver.rb#L229-L231 Templates that are inline or literals don't provide a "virtual path": https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/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: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/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.
* Bump license years for 2019Arun Agrawal2018-12-311-1/+1
|
* Bump license years for 2018Yoshiyuki Hirano2017-12-311-1/+1
|
* Remove unused `MissingRequestError`yuuji.yaginuma2017-10-311-1/+0
| | | | `MissingRequestError` is no longer used since 1e2b0ce.
* [Action View] require_relative => requireAkira Matsuda2017-10-211-1/+1
| | | | This basically reverts c4d1a4efeec6f0b5b58222993aa0bec85a19b6a8
* Use frozen string literal in actionview/Kir Shatrov2017-07-241-0/+2
|
* [Action View] require => require_relativeAkira Matsuda2017-07-011-1/+1
|
* Define path with __dir__bogdanvlviv2017-05-231-1/+1
| | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* Bump license years for 2017Jon Moss2016-12-311-1/+1
| | | | | | | | Per https://www.timeanddate.com/counters/firstnewyear.html, it's already 2017 in a lot of places, so we should bump the Rails license years to 2017. [ci skip]
* applies new string literal convention in actionview/libXavier Noria2016-08-061-4/+4
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Update copyright notices to 2016 [ci skip]Rashmi Yadav2015-12-311-1/+1
|
* Update copyright notices to 2015 [ci skip]Arun Agrawal2014-12-311-1/+1
|
* Now only requiring Loofah in the places where it is needed.Timm2014-06-161-1/+0
|
* Fixed uninitialized constant ActionView::HTML error entered after recent git ↵Timm2014-06-161-1/+0
| | | | rebase.
* Moved requiring of Loofah from sanitizers.rb to action_view.rb.Timm2014-06-151-0/+1
|
* just require the template resolverAaron Patterson2014-01-311-1/+0
| | | | | | LookupContext is eagerly loaded, and FallbackFileSystemResolver is referenced at the class level. Just require the resolver from the eagerly loaded class rather than jumping through autoload hoops
* only ask for the location filters onceAaron Patterson2014-01-311-2/+2
|
* Require actionview/versionWashington Luiz2014-01-061-0/+1
| | | | just like all the other modules do require their version file
* update copyright notices to 2014. [ci skip]Vipul A M2014-01-011-1/+1
|
* Make ActionView::Tags loading tread safeRafael Mendonça França2013-12-021-0/+1
|
* Load HTML in ActionView not ActionPackŁukasz Strzałkowski2013-08-251-0/+1
| | | | HTML Scanner is part of ActionView and it should be loaded along with it
* Fix eager_autoload for layoutsŁukasz Strzałkowski2013-08-251-1/+1
| | | | Name was singular, should be plural
* Move layouts to AVŁukasz Strzałkowski2013-08-251-0/+1
|
* Move rendering from AP to AVŁukasz Strzałkowski2013-08-251-0/+1
|
* Move view_paths from AP to AVŁukasz Strzałkowski2013-08-251-0/+1
|
* Remove require to AP stuff that leftŁukasz Strzałkowski2013-06-201-1/+0
|
* Move actionpack/lib/action_view* into actionview/libPiotr Sarnacki2013-06-201-2/+71
|
* Add bare actionview gem to the root directoryPiotr Sarnacki2013-06-201-0/+24
This commit creates structure for Action View gem and is first of a series of commits extracting Action View from Action Pack.