aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/renderer
Commit message (Collapse)AuthorAgeFilesLines
* Update to use Subscriber#start insteadPrem Sichanugrist2016-02-261-1/+0
| | | | | | | | We don't need to instrument another event as `ActiveSupport::LogSubscriber` already tracks when the instrumentation starts. Close #23717
* Added log "Rendering ...", when starting to render a template, to log that ↵Vipul A M2016-02-261-0/+1
| | | | | | | | we have started to render something, at the very beginning. This helps to easily identify queries from controller vs views Fixes #23710
* Lock down new `ImplicitRender` behavior for 5.0 RCGodfrey Chan2016-02-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* Instrument cached collection renders.Kasper Timm Hansen2016-02-203-16/+21
| | | | | | | | | | | | | | | | 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) ```
* Make collection caching explicit.Kasper Timm Hansen2016-02-202-33/+11
| | | | | | | | | | | | Having collection caching that wraps templates and automatically tries to infer if they are cachable proved to be too much of a hassle. We'd rather have it be something you explicitly turn on. This removes much of the code and docs to explain the previous automatic behavior. This change also removes scoped cache keys and passing cache_options.
* Prefer empty? to any?.Kasper Timm Hansen2016-02-121-1/+1
| | | | | | | If the collection isn't empty any? will loop through it. Spare the loop and be more concise with what we're asking the collection about.
* Stop mutating return value.Kasper Timm Hansen2016-02-121-2/+3
| | | | | | `PartialRenderer.render_collection_with/without_template` returns an array of rendered partials. Avoid dup'ing and shifting it by indexing into the collection instead.
* Inline `fetch_or_cache_partial`.Kasper Timm Hansen2016-02-121-10/+6
| | | | Wasn't pulling its weight for a simple yield anymore.
* Write to collection cache where the template is rendered.Kasper Timm Hansen2016-02-122-9/+15
| | | | | | | | Moves us closer to having access to a local template variable, we can ask for eligibility and its virtual_path. Currently we rely on `@template`, which we don't have available when rendering collections without a fixed template.
* Only write to collection cache if we have a callable cache key.Kasper Timm Hansen2016-02-121-1/+5
| | | | | | | | | | | A callable cache key writes to the collection cache under a certain namespace. Which means if we don't have scoped cache key we can just rely on the `cache model_name do` in the templates to cache them. Less writes, more sharing. Add `assert_customer_cached` to better illustrate this in tests, and remove tests which then don't communicate as much.
* Remove useless callable_cache_key? check.Kasper Timm Hansen2016-02-121-2/+1
| | | | | | `automatic_cache_eligible?´ is only called if there was no `:cache` key to fetch in the `@options` via `cache_collection?`. So the check will always be false.
* Remove single_template_render? method.Kasper Timm Hansen2016-02-121-5/+1
| | | | | | Written when I didn't understand the internals as well. Action View generally just refers to `@template` when meaning a fixed template render. So follow that implicit convention.
* Don't search in locals for cache_options.Kasper Timm Hansen2016-02-121-3/+1
| | | | | | We should only support a top level `cache_options`. We also don't have to default the options to a hash as Active Support's cache defaults that arg to nil.
* allow :file to be outside rails root, but anything else must be inside the ↵Aaron Patterson2016-01-222-2/+2
| | | | | | rails view directory CVE-2016-0752
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-11-151-1/+1
|\
| * [ci skip] Use full component name in public API documentyui-knk2015-11-151-1/+1
| |
* | Respect value of `:object` if `:object` is false when renderingyui-knk2015-11-131-1/+1
| | | | | | | | | | This commit fixes the bug convering `false` to `locals[as]` when `options[:object]` is `false` (close #22260).
* | Require only necessary concurrent-ruby classes.Jerry D'Antonio2015-11-041-1/+1
|/
* Replaced `ThreadSafe::Map` with successor `Concurrent::Map`.Jerry D'Antonio2015-09-191-3/+3
| | | | | | | The thread_safe gem is being deprecated and all its code has been merged into the concurrent-ruby gem. The new class, Concurrent::Map, is exactly the same as its predecessor except for fixes to two bugs discovered during the merge.
* Pass formats to lookup_contextRafael Mendonça França2015-08-241-1/+1
| | | | | | | | Before we were changing the state of the lookup_context for the duration of the with_layout_format block, but since we already know the formats we can just pass it explicitly. Related with 8d7ce0f22aee09d20091a4dc58cb379a09d13e26
* remove useless case in #resolve_layout.Nick Sutterer2015-08-241-2/+0
|
* remove LookupContext#with_layout_format by passing formats for layouts ↵Nick Sutterer2015-08-242-8/+11
| | | | explicitely.
* zOMG 37 objects savedschneems2015-07-301-1/+1
|
* Fix cache issue when different partials use the same collectionRoque Pinel2015-06-281-1/+1
| | | | | | | | | Adds the `virtual_path` option to `cache_fragment_name` so it can be provided when needed. That allows `cache_collection_render` to get the appropriate cache key with the digest generated based on the template and prevent collision with other templates that cache the same collection.
* Remove duplicate private statementRoque Pinel2015-06-211-2/+0
|
* spelling fix [ci skip]karanarora2015-05-191-1/+1
|
* Do not put partial name to local_assigns when rendering without an objectHenrik Nygren2015-05-141-1/+1
| | | | | | | | When one rendered a partial template without specifying an object or a collection (e.g. <%= render partial: 'partial_name' %>), Rails would make an object called :partial_name available in local_assigns. I don't think this was the intended behavior, since no local variable called 'partial_name' gets defined in the view.
* Merge pull request #19535 from JuanitoFatas/doc/av-commentYves Senn2015-03-271-1/+1
|\ | | | | [ci skip] Unify the code comment in ActionView::Renderer#render_template...
| * [ci skip] Unify the code comment in ActionView::Renderer#render_template.Juanito Fatas2015-03-271-1/+1
| |
* | Add missing :html option in determine_template error message.Juanito Fatas2015-03-271-1/+1
|/
* [ci skip] Fix `&>` with `%>`yui-knk2015-03-251-9/+9
|
* Collections automatically cache and fetch partials.Kasper Timm Hansen2015-02-211-2/+15
| | | | | | | | | | | | | | | | | | | | | | | Collections can take advantage of `multi_read` if they render one template and their partials begin with a cache call. The cache call must correspond to either what the collections elements are rendered as, or match the inferred name of the partial. So with a notifications/_notification.html.erb template like: ```ruby <% cache notification %> <%# ... %> <% end %> ``` A collection would be able to use `multi_read` if rendered like: ```ruby <%= render @notifications %> <%= render partial: 'notifications/notification', collection: @notifications, as: :notification %> ```
* Merge multi_fetch_fragments.Kasper Timm Hansen2015-02-202-2/+63
| | | | | | | | Makes caching a collection of template partials faster using `read_multi` on the Rails cache store. Some caching implementations have optimized `read_multi` so we don't have to check in the cache store for every template.
* Partial template name does no more have to be a valid Ruby identifierAkira Matsuda2015-02-061-3/+2
| | | | because the partial renderer would not create an lvar per each template since c67005f221f102fe2caca231027d9b11cf630484
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-01-031-5/+5
|\
| * Fix "Rendering" not to link to AV::Renderingclaudiob2014-12-251-5/+5
| | | | | | | | | | | | | | The "Rendering" word in the titles is not meant to be a link to the documentation for ActionView::Rendering. [ci skip]
* | fix error message of option as with invalid charters in partial renderingAngelo capilleri2014-12-291-2/+10
|/ | | | | before this PR IDENTIFIER_ERROR_MESSAGE could lead to misunderstand the convention of partial name. Added OPTION_AS_ERROR_MESSAGE for unvalid charter in as option.
* Fix warning in AV testsSean Griffin2014-11-251-2/+4
| | | | Originally caused by #17771
* Local vars should exist in partials for falsy `:object:` values tooAgis-2014-11-251-2/+2
| | | | | | | | | | | | c67005f221f102fe2caca231027d9b11cf630484 made the local var in partials available only if what passed to `:object` was truthy. For example this would not make the local variable `foo` available inside the partial: render partial: 'foo', object: false Fixes #17373.
* Avoid creating unneeded Hash instance and calling slow Hash#fetchAkira Matsuda2014-10-251-1/+1
|
* marking private methods which dont work if called on their own anywaysEugene Gilburg2014-07-182-1/+5
|
* small refactors to actionview renderersEugene Gilburg2014-07-183-16/+15
|
* Fix typo on the variable nameRafael Mendonça França2014-07-161-8/+8
|
* Document the PartialIteration objectRafael Mendonça França2014-07-161-3/+9
|
* Build only one PartialIteration object for loopRafael Mendonça França2014-07-161-11/+18
|
* No need to have a file to PartialIteration classRafael Mendonça França2014-07-161-1/+17
| | | | This class is only used on the PartialRenderer.
* Added PartialIteration class used when rendering collectionsJoel Junström2014-07-161-13/+28
| | | | | | | | | | | | The iteration object is available as the local variable "template_name_iteration" when rendering partials with collections. It gives access to the +size+ of the collection beeing iterated over, the current +index+ and two convinicence methods +first?+ and +last?+ "template_name_counter" variable is kept but is deprecated. [Joel Junström + Lucas Uyezu]
* Introduce `render :html` for render HTML stringPrem Sichanugrist2014-02-181-0/+2
| | | | | | | | | This is an option for to HTML content with a content type of `text/html`. This rendering option calls `ERB::Util.html_escape` internally to escape unsafe HTML string, so you will have to mark your string as html safe if you have any HTML tag in it. Please see #12374 for more detail.
* Introduce `render :plain` for render plain textPrem Sichanugrist2014-02-181-1/+3
| | | | | | | | This is as an option to render content with a content type of `text/plain`. This is the preferred option if you are planning to render a plain text content. Please see #12374 for more detail.
* Introduce `render :body` for render raw contentPrem Sichanugrist2014-02-181-2/+4
| | | | | | | | | | | | This is an option for sending a raw content back to browser. Note that this rendering option will unset the default content type and does not include "Content-Type" header back in the response. You should only use this option if you are expecting the "Content-Type" header to not be set. More information on "Content-Type" header can be found on RFC 2616, section 7.2.1. Please see #12374 for more detail.