aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/renderer/partial_renderer
Commit message (Collapse)AuthorAgeFilesLines
* Fix partial caching ignore repeated items issuest00122019-04-041-13/+20
| | | | | | This is because we only use hash to maintain the result. So when the key are the same, the result would be skipped. The solution is to maintain an array for tracking every item's position to restructure the result.
* Fix up styleAaron Patterson2019-02-191-1/+1
|
* Return rendered template information instead of just stringsAaron Patterson2019-02-191-4/+6
| | | | | | | | | | | | 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.
* Pass the template format to the digestorAaron Patterson2019-02-151-1/+1
| | | | | | | | | | | | | | | This commit passes the template format to the digestor in order to come up with a key. Before this commit, the digestor would depend on the side effect of the template renderer setting the rendered_format on the lookup context. I would like to remove that mutation, so I've changed this to pass the template format in to the digestor. I've introduced a new instance variable that will be alive during a template render. When the template is being rendered, it pushes the current template on to a stack, setting `@current_template` to the template currently being rendered. When the cache helper asks the digestor for a key, it uses the format of the template currently on the stack.
* Cache the digest path on the stack.Aaron Patterson2019-01-281-7/+5
| | | | We can remove the ivar by caching the digest on the stack
* Pull `@template` in to a local variableAaron Patterson2019-01-281-8/+8
| | | | | | This gets the PartialRenderer to be a bit closer to the TemplateRenderer. TemplateRenderer already keeps its template in a local variable.
* Remove `@view` instance variable from the partial rendererAaron Patterson2019-01-281-8/+8
| | | | Similar to 1853b0d0abf87dfdd4c3a277c3badb17ca19652e
* [ci skip] document collection_caching.rbschneems2018-09-191-0/+35
|
* Move digest path calculation out of loopschneems2018-09-111-1/+5
| | | | | | | | | | | On every iteration of generating a cache for a collection a “digest path” is calculated even though it’s exactly the same for every element. This PR exposes a method `digest_path_from_virtual` that returns back a “digest_path”. This can in turn be passed back into `cache_fragment_name`. This not only does less work, but it also (you guessed it) uses less memory. before: Total allocated: 762539 bytes (7035 objects) after: Total allocated: 743590 bytes (6621 objects) (762539 - 743590)/ 762539.0 # => 2.4% faster ⚡️⚡️
* Use frozen string literal in actionview/Kir Shatrov2017-07-241-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-031-1/+1
|
* Use recyclable cache keys (#29092)David Heinemeier Hansson2017-05-181-1/+1
|
* Bring back support for callable cache_key on collection renderingIgnatius Reza2016-07-211-1/+7
|
* Instrument cached collection renders.Kasper Timm Hansen2016-02-201-2/+3
| | | | | | | | | | | | | | | | 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-201-26/+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-121-9/+8
| | | | | | | | 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.
* 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.
* spelling fix [ci skip]karanarora2015-05-191-1/+1
|
* 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-201-0/+57
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.