render_async 2.1.4 → 2.1.9

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.
@@ -11,3 +11,10 @@ cd spec/fixtures/rails-5-base-app
11
11
  ls
12
12
  bundle install
13
13
  bundle exec cucumber
14
+
15
+ cd ../../../spec/fixtures/rails-6-base-app
16
+ ls
17
+ bundle install
18
+ yarn install
19
+ RAILS_ENV=test bundle exec rails webpacker:compile
20
+ bundle exec cucumber
@@ -1,10 +1,13 @@
1
1
  module RenderAsync
2
2
  class Configuration
3
- attr_accessor :jquery, :turbolinks
3
+ attr_accessor :jquery, :turbolinks, :turbo, :replace_container, :nonces
4
4
 
5
5
  def initialize
6
6
  @jquery = false
7
7
  @turbolinks = false
8
+ @turbo = false
9
+ @replace_container = true
10
+ @nonces = false
8
11
  end
9
12
  end
10
13
  end
@@ -1,3 +1,3 @@
1
1
  module RenderAsync
2
- VERSION = "2.1.4".freeze
2
+ VERSION = "2.1.9".freeze
3
3
  end
@@ -2,7 +2,6 @@ require 'securerandom'
2
2
 
3
3
  module RenderAsync
4
4
  module ViewHelper
5
-
6
5
  def render_async_cache_key(path)
7
6
  "render_async_#{path}"
8
7
  end
@@ -20,18 +19,17 @@ module RenderAsync
20
19
  def render_async(path, options = {}, &placeholder)
21
20
  event_name = options.delete(:event_name)
22
21
  placeholder = capture(&placeholder) if block_given?
23
- retry_count = options.delete(:retry_count) || 0
24
- html_options = options.delete(:html_options) || {}
25
22
 
26
23
  render 'render_async/render_async', **container_element_options(options),
27
24
  path: path,
28
- html_options: html_options,
25
+ html_options: html_options(options),
29
26
  event_name: event_name,
30
27
  placeholder: placeholder,
31
28
  **request_options(options),
32
29
  **error_handling_options(options),
33
- retry_count: retry_count,
34
- **polling_options(options)
30
+ **retry_options(options),
31
+ **polling_options(options),
32
+ **content_for_options(options)
35
33
  end
36
34
 
37
35
  private
@@ -39,7 +37,16 @@ module RenderAsync
39
37
  def container_element_options(options)
40
38
  { html_element_name: options[:html_element_name] || 'div',
41
39
  container_id: options[:container_id] || generate_container_id,
42
- container_class: options[:container_class] }
40
+ container_class: options[:container_class],
41
+ replace_container: replace_container(options) }
42
+ end
43
+
44
+ def html_options(options)
45
+ set_options = options.delete(:html_options) || {}
46
+
47
+ set_options[:nonce] = configuration.nonces if set_options[:nonce].nil?
48
+
49
+ set_options
43
50
  end
44
51
 
45
52
  def request_options(options)
@@ -53,15 +60,36 @@ module RenderAsync
53
60
  error_event_name: options[:error_event_name] }
54
61
  end
55
62
 
63
+ def retry_options(options)
64
+ {
65
+ retry_count: options.delete(:retry_count) || 0,
66
+ retry_delay: options.delete(:retry_delay)
67
+ }
68
+ end
69
+
56
70
  def polling_options(options)
57
71
  { interval: options[:interval],
58
72
  toggle: options[:toggle] }
59
73
  end
60
74
 
61
- private
75
+ def content_for_options(options)
76
+ {
77
+ content_for_name: options[:content_for_name] || :render_async
78
+ }
79
+ end
62
80
 
63
81
  def generate_container_id
64
82
  "render_async_#{SecureRandom.hex(5)}#{Time.now.to_i}"
65
83
  end
84
+
85
+ def replace_container(options)
86
+ return options[:replace_container] unless options[:replace_container].nil?
87
+
88
+ configuration.replace_container
89
+ end
90
+
91
+ def configuration
92
+ RenderAsync.configuration
93
+ end
66
94
  end
67
95
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Grubbe
8
8
  - nikolalsvk
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-11-11 00:00:00.000000000 Z
12
+ date: 2021-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -61,6 +61,8 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - ".all-contributorsrc"
64
+ - ".github/CONTRIBUTING.md"
65
+ - ".github/FUNDING.yml"
64
66
  - ".gitignore"
65
67
  - ".gitmodules"
66
68
  - ".rspec"
@@ -85,7 +87,7 @@ homepage: https://github.com/renderedtext/render_async
85
87
  licenses:
86
88
  - MIT
87
89
  metadata: {}
88
- post_install_message:
90
+ post_install_message:
89
91
  rdoc_options: []
90
92
  require_paths:
91
93
  - lib
@@ -100,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.7.6
105
- signing_key:
105
+ rubygems_version: 3.0.3
106
+ signing_key:
106
107
  specification_version: 4
107
108
  summary: Render parts of the page asynchronously with AJAX
108
109
  test_files: []