step_render 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -1
- data/app/controllers/step_load_controller.rb +1 -1
- data/lib/step_render/version.rb +1 -1
- data/lib/step_render/view_helper.rb +3 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bba6f547ad110f7ade5623bf045adb5ae2aab594
|
4
|
+
data.tar.gz: 6af12bfab5fa1c24dda036dbac35056feb9a0efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d558f6d89e80bb8e6e5ac831cb462a294dd48a428619f0cecb7dadd7be90d32ddbe95d68caeffee24b898b230f2f8926967e239489bc7308a03cd697dc7684f8
|
7
|
+
data.tar.gz: eb38b11ae4f5b4b391274b8638c614e7125e95fff1b788c1ed31e790d332fa19673c58c1c1eb6c165098d437d37ed88bae385c2320724836c6c3709add6f4eee
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@ It is very easy to enable lazy loading of partial with scroll in views.
|
|
3
3
|
|
4
4
|
You only use `step_render` method instead of `render` method.
|
5
5
|
|
6
|
+
Likewise, you can lazy load a fragment cache.
|
7
|
+
|
6
8
|
## Installation
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
@@ -15,7 +17,7 @@ And then execute:
|
|
15
17
|
$ bundle
|
16
18
|
```
|
17
19
|
|
18
|
-
## Usage
|
20
|
+
## Usage 1: Lazy Load Partial
|
19
21
|
|
20
22
|
### 1. Load javascript library
|
21
23
|
|
@@ -46,6 +48,23 @@ Partial must be specified as an absolute path.
|
|
46
48
|
<%= step_render 'top/partial_name' %>
|
47
49
|
```
|
48
50
|
|
51
|
+
## Usage 2: Lazy Load fragment cache
|
52
|
+
|
53
|
+
### 1. Load javascript library
|
54
|
+
|
55
|
+
### 2. Use `step_cache` method instead of `cache` method
|
56
|
+
|
57
|
+
Replace `cache` helper method used to fragment cache with `step_render`.
|
58
|
+
|
59
|
+
#### Example
|
60
|
+
|
61
|
+
`app/views/top/index.html.erb`
|
62
|
+
```html
|
63
|
+
<%= step_cache 'cache_key', skip_digest: true, expires_in: 24.hours %>
|
64
|
+
~~~
|
65
|
+
~~~html tags
|
66
|
+
```
|
67
|
+
|
49
68
|
## Contributing
|
50
69
|
Contribution directions go here.
|
51
70
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class StepLoadController < ApplicationController
|
3
3
|
layout false
|
4
4
|
def partial
|
5
|
-
@options =
|
5
|
+
@options = Marshal.load(CGI.unescape(params[:key]))
|
6
6
|
render inline: "<%= render *@options %>"
|
7
7
|
end
|
8
8
|
|
data/lib/step_render/version.rb
CHANGED
@@ -2,11 +2,9 @@
|
|
2
2
|
module StepRender
|
3
3
|
module ViewHelper
|
4
4
|
def step_render(*options)
|
5
|
-
key =
|
6
|
-
|
7
|
-
|
8
|
-
# Rails.cache.fetch(key, skip_digest: true, expires_in: 10.minute) { ActiveJob::Arguments.serialize(options) }
|
9
|
-
%(<div class= "related-articles lazyload" data-include="#{step_render_path(key)}">loading</div>).html_safe
|
5
|
+
key = CGI.escape(Marshal.dump(options))
|
6
|
+
path = step_render_path(key)
|
7
|
+
%(<div class= "related-articles lazyload" data-include="#{path}">loading</div>).html_safe
|
10
8
|
end
|
11
9
|
|
12
10
|
def step_cache(key, **options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: step_render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EastResident
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|