-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Summary
Add a class method to slice class allowing easy fragment caching of the entire view
Motivation
To add this currently means wrapping the entire view in a cache
block
For example, consider FooSlice
:
# app/slices/foo/foo_slice.rb
class FooSlice < Slice
end
<!-- app/slices/foo/views/show.html.erb -->
<div>
<p>
<%= some_expensive_method %>
</p>
</div>
Adding the cache
block would give the resulting code, potentially adding an extra level of indentation to most of the file.
<!-- app/slices/foo/views/show.html.erb -->
<% cache slice do %>
<div>
<p>
<%= some_expensive_method %>
</p>
</div>
<% end %>
Rather then having to add a cache
block to the view, we would prefer to add a class method/macro to the slice to signify that the entire view should be fragment cached.
# app/slices/foo/foo_slice.rb
class FooSlice < Slice
fragment_cache_view
end
This method could allow the passing of optional extra cache keys:
fragment_cache_view 'addition-key'
Metadata
Metadata
Assignees
Labels
No labels