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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbe9e7181411e275d6d83a2cad55bbeda8b5a916126ae329aa13b1b7094ef1a1
4
- data.tar.gz: 8f56056e24da138c598733ca23dd29a0e96099aa202d4e11f01a5fb349759484
3
+ metadata.gz: 07f60542cc60eadcaaac779c133d7c7b31d038fc622c45b95e1a93bb2d5fe61d
4
+ data.tar.gz: d9479d1b20744c907fdb1233d0175a9ba149e80aae553e2714909fcccaecc4df
5
5
  SHA512:
6
- metadata.gz: 7cabdacc90ec1898d40880320346996ed5ee370ce50dbdfcd3c350d52e63a13df1d679e9b399c1cc35069a764287406028041ad62aba08a72412771a3bf8bf55
7
- data.tar.gz: d0c6db32c886243158c432f03b5f950734c81d9a4ede9ac10a82f0b72bf8eb1208d5e74c07874257d285c3ba859331da6c9874ba10e009bde4208a83c4aebdda
6
+ metadata.gz: a2b2918895fab273b0e01ea22e4fe483c1466ae05053ea5c4ed88b2014e0dd8bb010fb993a295110725a255fd4165a0f873422d376f8743cd31fb4ecb37b5acf
7
+ data.tar.gz: f7d6660ca9e18978a5e34e6f260383c7a847c74e9ea88b38af1c021cff93a2c0a2f3c52004807da7f8a3f6836345fff6ac4508153747f63e377c21066883b385
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- render_later (0.1.0)
4
+ render_later (0.1.1)
5
5
  rack
6
6
 
7
7
  GEM
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-31-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
17
- [![Maintainability](https://api.codeclimate.com/v1/badges/2b24fdbd1ae37a24bedb/maintainability)](https://codeclimate.com/github/hopsoft/render_later/maintainability)
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
- Inspired by: https://github.com/renderedtext/render_async
25
+ ## Quick Start
26
26
 
27
- This libary uses [Stimulus](https://stimulusjs.org) to avoid injecting multiple JavaScript tags into the body.
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
- ## app/assets/javascripts/application.js
33
+ 2. `app/assets/javascripts/application.js`
38
34
 
39
35
  ```javascript
40
36
  //= require render_later
41
37
  ```
42
38
 
43
- ## app/views/any_erb_template.html.erb
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
- <%= render_later "/path/to/section" %>
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
- # How it Works
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
- render "/render_later", url: url, css: css, style: style, &block
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
@@ -1,3 +1,3 @@
1
1
  module RenderLater
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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
@@ -1,4 +0,0 @@
1
- <span data-controller="render-later" data-url="<%= url %>" class="<%= css %>" style="<%= style %>">
2
- <% html = yield %>
3
- <%= html.present? ? html : "Loading..." %>
4
- </span>