render_later 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +44 -12
- data/app/helpers/render_later_helper.rb +2 -2
- data/lib/render_later/version.rb +1 -1
- metadata +1 -2
- data/app/views/_render_later.html.erb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07f60542cc60eadcaaac779c133d7c7b31d038fc622c45b95e1a93bb2d5fe61d
|
4
|
+
data.tar.gz: d9479d1b20744c907fdb1233d0175a9ba149e80aae553e2714909fcccaecc4df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2b2918895fab273b0e01ea22e4fe483c1466ae05053ea5c4ed88b2014e0dd8bb010fb993a295110725a255fd4165a0f873422d376f8743cd31fb4ecb37b5acf
|
7
|
+
data.tar.gz: f7d6660ca9e18978a5e34e6f260383c7a847c74e9ea88b38af1c021cff93a2c0a2f3c52004807da7f8a3f6836345fff6ac4508153747f63e377c21066883b385
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,8 +13,8 @@
|
|
13
13
|
|
14
14
|
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
15
15
|
|
16
|
-
[![Lines of Code](http://img.shields.io/badge/lines_of_code-
|
17
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/
|
16
|
+
[![Lines of Code](http://img.shields.io/badge/lines_of_code-27-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
|
17
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/a0661a5ab84b7b83b5aa/maintainability)](https://codeclimate.com/github/hopsoft/render_later/maintainability)
|
18
18
|
|
19
19
|
# RenderLater
|
20
20
|
|
@@ -22,31 +22,58 @@
|
|
22
22
|
|
23
23
|
Render sections of the page asynchronously after initial page load.
|
24
24
|
|
25
|
-
|
25
|
+
## Quick Start
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
# Quick Start
|
30
|
-
|
31
|
-
## Gemfile
|
27
|
+
1. `Gemfile`
|
32
28
|
|
33
29
|
```ruby
|
34
30
|
gem "render_later"
|
35
31
|
```
|
36
32
|
|
37
|
-
|
33
|
+
2. `app/assets/javascripts/application.js`
|
38
34
|
|
39
35
|
```javascript
|
40
36
|
//= require render_later
|
41
37
|
```
|
42
38
|
|
43
|
-
|
39
|
+
3. `app/views/any_erb_template.html.erb`
|
40
|
+
|
41
|
+
```erb
|
42
|
+
<%= render_later "/some/slow/url" %>
|
43
|
+
```
|
44
|
+
|
45
|
+
## Next Steps
|
46
|
+
|
47
|
+
### Style the placeholder element
|
48
|
+
|
49
|
+
You may wish to style the placeholder.
|
50
|
+
This can be done by passing `css` and `style` arguments to `render_later`
|
51
|
+
|
52
|
+
```erb
|
53
|
+
<%= render_later "/some/slow/url", css: "css-class", style: "color:red" %>
|
54
|
+
```
|
55
|
+
|
56
|
+
### Add loading content
|
44
57
|
|
58
|
+
The text content `Loading...` displays by default.
|
59
|
+
This can be overridden by passing a block to `render_later`
|
60
|
+
|
61
|
+
```erb
|
62
|
+
<%= render_later "/some/slow/url" do %>
|
63
|
+
<%= image_tag "spinner.gif" %>
|
64
|
+
<% end %>
|
45
65
|
```
|
46
|
-
|
66
|
+
|
67
|
+
### Change the Placeholder Tag
|
68
|
+
|
69
|
+
A `span` placeholder tag is used by default.
|
70
|
+
This can be overridden by passing the `tag` argument to `render_later`
|
71
|
+
|
72
|
+
```erb
|
73
|
+
<%= render_later "/some/slow/url", tag: "tr" %>
|
47
74
|
```
|
48
75
|
|
49
|
-
|
76
|
+
## How it Works
|
50
77
|
|
51
78
|
1. Site visitor requests a page
|
52
79
|
1. Server renders a response
|
@@ -54,6 +81,11 @@ gem "render_later"
|
|
54
81
|
1. [XHR](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) is used to fetch `render_later` sections asynchronously
|
55
82
|
1. The DOM is updated with the asyncrhonously loaded HTML
|
56
83
|
|
84
|
+
## Similar Tools
|
85
|
+
|
86
|
+
- https://github.com/renderedtext/render_async
|
87
|
+
- https://github.com/jarthod/render-later
|
88
|
+
|
57
89
|
## JavaScript Development
|
58
90
|
|
59
91
|
The JavaScript source is located in `app/assets/javascripts/src`
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module RenderLaterHelper
|
2
|
-
def render_later(url, css: nil, style: nil, &block)
|
3
|
-
|
2
|
+
def render_later(url, tag_name: "span", css: nil, style: nil, &block)
|
3
|
+
content_tag tag_name, "Loading...", class: css, style: style, data: {controller: "render-later", url: url}, &block
|
4
4
|
end
|
5
5
|
end
|
data/lib/render_later/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_later
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- Rakefile
|
81
81
|
- app/assets/javascripts/render_later.js
|
82
82
|
- app/helpers/render_later_helper.rb
|
83
|
-
- app/views/_render_later.html.erb
|
84
83
|
- lib/render_later.rb
|
85
84
|
- lib/render_later/version.rb
|
86
85
|
homepage: https://github.com/hopsoft/render_later
|