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

20 commits

Author SHA1 Message Date
Ryuta Kamizono
c81af6ae72 Enable Layout/EmptyLinesAroundAccessModifier cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
Abhay Nikam
1de6a20a6d Removed unused layout attribute from RenderedTemplate 2019-03-09 11:54:42 +05:30
Aaron Patterson
ca5e23ed4d
Templates have one format
Templates only have one format.  Before this commit, templates would be
constructed with a single element array that contained the format.  This
commit eliminates the single element array and just implements a
`format` method.  This saves one array allocation per template.
2019-02-25 13:18:44 -08:00
Aaron Patterson
62cb3ee35c
Ensure that rendered templates always have a format
This removes one call to `lookup_context` and also eliminates a
conditional in `_render_template`.
2019-02-22 11:58:04 -08:00
Aaron Patterson
3f84a814aa
Fix up style 2019-02-19 14:57:29 -08:00
Aaron Patterson
1bc0a59d6e
Return rendered template information instead of just strings
This commit introduces "rendered template" and "rendered collection"
objects.  The template renderers can now return a more complex object
than just strings.  This allows the framework to get more information
about the templates that were rendered.  In this commit we use the
rendered template object to set the "rendered_format" on the lookup
context in the controller rather than all the way in the template renderer.
That means we don't need to check the "rendered_format" every time we
render a template, we just do it once after all templates have been
rendered.
2019-02-19 13:46:09 -08:00
Aaron Patterson
736db1586e
Remove with_layout_format delegation
That method doesn't exist on LookupContext, so the delegate doesn't make
sense.
2019-01-28 15:09:13 -08:00
Aaron Patterson
5bb1ad59b1
Pull @template in to a local variable
This gets the PartialRenderer to be a bit closer to the
TemplateRenderer.  TemplateRenderer already keeps its template in a
local variable.
2019-01-28 14:55:12 -08:00
Aaron Patterson
bd3bea1598
Remove find_template and find_file delegate methods
This reduces the surface area of our API and removes a Liskov issue.
Both TemplateRenderer and PartialRenderer inherit from AbstractRenderer,
but since PartialRenderer implements it's own `find_template` that is
private, and has the wrong method signature, an instance of
PartialRenderer cannot be substituted for an instance of
AbstractRenderer renderer.  Removing the superclass implementation
solves both issues.
2019-01-28 14:12:08 -08:00
Kir Shatrov
424117281e Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590, reversing
changes made to afb66a5a59.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Akira Matsuda
7f998540af Privatize unneededly protected methods in Action View 2016-12-24 22:16:47 +09:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
63fff600ac modernizes hash syntax in actionview 2016-08-06 19:36:34 +02:00
Godfrey Chan
73b1efc58f Lock down new ImplicitRender behavior for 5.0 RC
1. Conceptually revert #20276

   The feature was implemented for the `responders` gem. In the end,
   they did not need that feature, and have found a better fix (see
   plataformatec/responders#131).

   `ImplicitRender` is the place where Rails specifies our default
   policies for the case where the user did not explicitly tell us
   what to render, essentially describing a set of heuristics. If
   the gem (or the user) knows exactly what they want, they could
   just perform the correct `render` to avoid falling through to
   here, as `responders` did (the user called `respond_with`).

   Reverting the patch allows us to avoid exploding the complexity
   and defining “the fallback for a fallback” policies.

2. `respond_to` and templates are considered exhaustive enumerations

   If the user specified a list of formats/variants in a `respond_to`
   block, anything that is not explicitly included should result
   in an `UnknownFormat` error (which is then caught upstream to
   mean “406 Not Acceptable” by default). This is already how it
   works before this commit.

   Same goes for templates – if the user defined a set of templates
   (usually in the file system), that set is now considered exhaustive,
   which means that “missing” templates are considered `UnknownFormat`
   errors (406).

3. To keep API endpoints simple, the implicit render behavior for
   actions with no templates defined at all (regardless of formats,
   locales, variants, etc) are defaulted to “204 No Content”. This
   is a strictly narrower version of the feature landed in #19036 and
   #19377.

4. To avoid confusion when interacting in the browser, these actions
   will raise an `UnknownFormat` error for “interactive” requests
   instead. (The precise definition of “interactive” requests might
   change – the spirit here is to give helpful messages and avoid
   confusions.)

Closes #20666, #23062, #23077, #23564

[Godfrey Chan, Jon Moss, Kasper Timm Hansen, Mike Clark, Matthew Draper]
2016-02-25 01:19:49 -08:00
Kasper Timm Hansen
b4700de1ce Instrument cached collection renders.
Augments the collection caching with some instrumentation that's logged.

For collections that have been cached like:

```ruby
<%= render partial: 'notifications/notification', collection: @notifications, cached: true %>
```

We'll output a line showing how many cache hits we had when rendering it:

```
  Rendered collection of notifications/_notification.html.erb [0 / 100 cache hits] (3396.5ms)
```
2016-02-20 18:34:41 +01:00
Aaron Patterson
b7758b40fc allow :file to be outside rails root, but anything else must be inside the rails view directory
CVE-2016-0752
2016-01-22 15:02:27 -08:00
Eugene Gilburg
38117adfe3 small refactors to actionview renderers 2014-07-18 20:54:03 -07:00
Piotr Sarnacki
0d6e8edc2a Move actionpack/lib/action_view* into actionview/lib 2013-06-20 17:23:15 +02:00
Renamed from actionpack/lib/action_view/renderer/abstract_renderer.rb (Browse further)