phlex-rails 0.7.1 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -26
- data/Appraisals +2 -2
- data/README.md +1 -1
- data/lib/phlex/rails/buffered.rb +2 -2
- data/lib/phlex/rails/helper_macros.rb +3 -3
- data/lib/phlex/rails/helpers/tag.rb +1 -1
- data/lib/phlex/rails/helpers.rb +7 -0
- data/lib/phlex/rails/sgml/overrides.rb +22 -68
- data/lib/phlex/rails/unbuffered_overrides.rb +29 -0
- data/lib/phlex/rails/version.rb +1 -1
- data/lib/phlex/rails.rb +4 -1
- metadata +5 -5
- data/lib/phlex/rails/sgml/append_method_added_warning.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d500a3ff8d27e51acd27c6901159a5878ee3bf86548d621e4d3deae2d04ad18
|
4
|
+
data.tar.gz: 076fce2ab65191941c6f5f7e72e861e9f0c8768909051977c840661b76811d90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a48694a35ddc236320b5467548cf5a509a8cd6cb069277aa39109be4e49f6d299459b14a2c8d8afa3debc559deecdec90743536fbad42b2e2ba4250aadcb7d92
|
7
|
+
data.tar.gz: 3dbd6856b20b5c27471cded9cb6600da3d71de126134564b9367eafa88bdbf3c9e18463c442892d63d58ac118a3c39d91959dd52be6b8aba373071cc4b7d75fb
|
data/.rubocop.yml
CHANGED
@@ -6,31 +6,7 @@ AllCops:
|
|
6
6
|
TargetRubyVersion: 2.7
|
7
7
|
Exclude:
|
8
8
|
- "lib/phlex-rails.rb"
|
9
|
+
SuggestExtensions: false
|
9
10
|
|
10
|
-
Style/
|
11
|
-
Enabled: false
|
12
|
-
|
13
|
-
Layout/CaseIndentation:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
Style/StringConcatenation:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Layout/MultilineMethodCallBraceLayout:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
|
23
|
-
Security/Eval:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
Style/MethodCallWithoutArgsParentheses:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
Style/MixinUsage:
|
30
|
-
Enabled: false
|
31
|
-
|
32
|
-
Style/ConditionalAssignment:
|
33
|
-
Enabled: false
|
34
|
-
|
35
|
-
Lint/UnderscorePrefixedVariableName:
|
11
|
+
Style/MissingRespondToMissing:
|
36
12
|
Enabled: false
|
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Documentation can be found at [www.phlex.fun](https://www.phlex.fun).
|
|
8
8
|
|
9
9
|
### Support ✋
|
10
10
|
|
11
|
-
If you run into any trouble, please [start a discussion](https://github.com/joeldrapper/phlex/discussions/new), or [open an issue](https://github.com/joeldrapper/phlex/issues/new) if you think you’ve found a bug.
|
11
|
+
If you run into any trouble, please [start a discussion](https://github.com/joeldrapper/phlex/discussions/new), or [open an issue](https://github.com/joeldrapper/phlex-rails/issues/new) if you think you’ve found a bug.
|
12
12
|
|
13
13
|
### Community 🙌
|
14
14
|
|
data/lib/phlex/rails/buffered.rb
CHANGED
@@ -29,7 +29,7 @@ module Phlex::Rails
|
|
29
29
|
|
30
30
|
case output
|
31
31
|
when ::ActiveSupport::SafeBuffer
|
32
|
-
@view.instance_variable_get(:@
|
32
|
+
@view.instance_variable_get(:@_context).target << output
|
33
33
|
end
|
34
34
|
|
35
35
|
nil
|
@@ -56,7 +56,7 @@ module Phlex::Rails
|
|
56
56
|
|
57
57
|
case output
|
58
58
|
when ::ActiveSupport::SafeBuffer
|
59
|
-
@view.instance_variable_get(:@
|
59
|
+
@view.instance_variable_get(:@_context).target << output
|
60
60
|
end
|
61
61
|
|
62
62
|
nil
|
@@ -11,7 +11,7 @@ module Phlex::Rails::HelperMacros
|
|
11
11
|
|
12
12
|
case output
|
13
13
|
when ActiveSupport::SafeBuffer
|
14
|
-
@
|
14
|
+
@_context.target << output
|
15
15
|
end
|
16
16
|
|
17
17
|
nil
|
@@ -32,7 +32,7 @@ module Phlex::Rails::HelperMacros
|
|
32
32
|
|
33
33
|
case output
|
34
34
|
when ActiveSupport::SafeBuffer
|
35
|
-
@
|
35
|
+
@_context.target << output
|
36
36
|
end
|
37
37
|
|
38
38
|
nil
|
@@ -85,7 +85,7 @@ module Phlex::Rails::HelperMacros
|
|
85
85
|
|
86
86
|
case output
|
87
87
|
when ActiveSupport::SafeBuffer
|
88
|
-
@
|
88
|
+
@_context.target << output
|
89
89
|
end
|
90
90
|
|
91
91
|
nil
|
data/lib/phlex/rails/helpers.rb
CHANGED
@@ -1306,6 +1306,13 @@ module Phlex::Rails::Helpers
|
|
1306
1306
|
define_output_helper :url_field_tag
|
1307
1307
|
end
|
1308
1308
|
|
1309
|
+
module URLFor
|
1310
|
+
extend Phlex::Rails::HelperMacros
|
1311
|
+
|
1312
|
+
# @!method url_for(...)
|
1313
|
+
define_value_helper :url_for
|
1314
|
+
end
|
1315
|
+
|
1309
1316
|
module URLOptions
|
1310
1317
|
extend Phlex::Rails::HelperMacros
|
1311
1318
|
|
@@ -17,9 +17,9 @@ module Phlex
|
|
17
17
|
return super if renderable.is_a?(Class) && renderable < Phlex::SGML
|
18
18
|
|
19
19
|
if renderable
|
20
|
-
@
|
20
|
+
@_context.target << @_view_context.render(renderable, *args, **kwargs, &block)
|
21
21
|
else
|
22
|
-
@
|
22
|
+
@_context.target << @_view_context.render(*args, **kwargs, &block)
|
23
23
|
end
|
24
24
|
|
25
25
|
nil
|
@@ -28,92 +28,46 @@ module Phlex
|
|
28
28
|
def render_in(view_context, &block)
|
29
29
|
if block_given?
|
30
30
|
call(view_context: view_context) do |*args|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
31
|
+
original_length = @_context.target.length
|
32
|
+
|
33
|
+
if args.length == 1 && Phlex::SGML === args[0]
|
34
|
+
output = view_context.capture(
|
35
|
+
args[0].unbuffered, &block
|
36
|
+
)
|
37
|
+
else
|
38
|
+
output = view_context.capture(*args, &block)
|
39
|
+
end
|
41
40
|
|
42
|
-
|
41
|
+
unchanged = (original_length == @_context.target.length)
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
text(output)
|
49
|
-
end
|
43
|
+
if unchanged
|
44
|
+
case output
|
45
|
+
when ActiveSupport::SafeBuffer
|
46
|
+
@_context.target << output
|
50
47
|
end
|
51
48
|
end
|
52
|
-
|
53
|
-
nil
|
54
49
|
end.html_safe
|
55
50
|
else
|
56
51
|
call(view_context: view_context).html_safe
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
60
|
-
|
61
|
-
|
62
|
-
return unless value
|
63
|
-
|
64
|
-
@_target << case value
|
65
|
-
when String then value
|
66
|
-
when Symbol then value.name
|
67
|
-
else value.to_s
|
68
|
-
end
|
55
|
+
def capture
|
56
|
+
super&.html_safe
|
69
57
|
end
|
70
58
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
# @api private
|
75
|
-
def append=(value)
|
76
|
-
case value
|
59
|
+
def plain(content)
|
60
|
+
case content
|
77
61
|
when ActiveSupport::SafeBuffer
|
78
|
-
@
|
62
|
+
@_context.target << content
|
79
63
|
else
|
80
|
-
|
81
|
-
when String then ERB::Util.html_escape(value)
|
82
|
-
when Symbol then ERB::Util.html_escape(value.name)
|
83
|
-
else ERB::Util.html_escape(value.to_s)
|
84
|
-
end
|
64
|
+
super
|
85
65
|
end
|
86
66
|
end
|
87
67
|
|
88
|
-
def capture
|
89
|
-
super&.html_safe
|
90
|
-
end
|
91
|
-
|
92
68
|
# Trick ViewComponent into thinking we're a ViewComponent to fix rendering output
|
93
69
|
def set_original_view_context(view_context)
|
94
70
|
end
|
95
|
-
|
96
|
-
private def yield_content(&block)
|
97
|
-
return unless block
|
98
|
-
|
99
|
-
case block.binding.receiver
|
100
|
-
when Phlex::SGML
|
101
|
-
super
|
102
|
-
else
|
103
|
-
@_view_context.with_output_buffer(self) { super }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
private def yield_content_with_args(*args, &block)
|
108
|
-
return unless block
|
109
|
-
|
110
|
-
case block.binding.receiver
|
111
|
-
when Phlex::SGML
|
112
|
-
super
|
113
|
-
else
|
114
|
-
@_view_context.with_output_buffer(self) { super }
|
115
|
-
end
|
116
|
-
end
|
117
71
|
end
|
118
72
|
end
|
119
73
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlex::Rails::UnbufferedOverrides
|
4
|
+
def method_missing(name, *args, **kwargs, &block)
|
5
|
+
if @object.respond_to?(name)
|
6
|
+
|
7
|
+
__class__.define_method(name) do |*a, **k, &b|
|
8
|
+
@object.capture do
|
9
|
+
if b
|
10
|
+
@object.public_send(name, *a, **k) do |*aa|
|
11
|
+
if aa.length == 1 && aa[0].is_a?(Phlex::SGML)
|
12
|
+
@object.helpers.capture(aa[0].unbuffered, &b)
|
13
|
+
else
|
14
|
+
@object.helpers.capture(*aa, &b)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
else
|
18
|
+
@object.public_send(name, *a, **k)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Now we've defined this missing method, we can call it.
|
24
|
+
__public_send__(name, *args, **kwargs, &block)
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/phlex/rails/version.rb
CHANGED
data/lib/phlex/rails.rb
CHANGED
@@ -18,7 +18,6 @@ module Phlex
|
|
18
18
|
|
19
19
|
class SGML
|
20
20
|
extend Phlex::Rails::SGML::ClassMethods
|
21
|
-
extend Phlex::Rails::SGML::AppendMethodAddedWarning
|
22
21
|
|
23
22
|
prepend Phlex::Rails::SGML::Overrides
|
24
23
|
end
|
@@ -27,4 +26,8 @@ module Phlex
|
|
27
26
|
extend Phlex::Rails::HTML::Format
|
28
27
|
include Phlex::Rails::HTML::Format
|
29
28
|
end
|
29
|
+
|
30
|
+
class Unbuffered
|
31
|
+
prepend ::Phlex::Rails::UnbufferedOverrides
|
32
|
+
end
|
30
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlex-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Drapper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,9 +111,9 @@ files:
|
|
111
111
|
- lib/phlex/rails/helpers/turbo_stream.rb
|
112
112
|
- lib/phlex/rails/html/format.rb
|
113
113
|
- lib/phlex/rails/layout.rb
|
114
|
-
- lib/phlex/rails/sgml/append_method_added_warning.rb
|
115
114
|
- lib/phlex/rails/sgml/class_methods.rb
|
116
115
|
- lib/phlex/rails/sgml/overrides.rb
|
116
|
+
- lib/phlex/rails/unbuffered_overrides.rb
|
117
117
|
- lib/phlex/rails/version.rb
|
118
118
|
- lib/phlex/testing/rails/view_helper.rb
|
119
119
|
- phlex_logo.png
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Rails
|
5
|
-
module SGML
|
6
|
-
module AppendMethodAddedWarning
|
7
|
-
def method_added(name)
|
8
|
-
if name == :append || name == :safe_append= || name == :safe_concat
|
9
|
-
raise Phlex::NameError, "You shouldn't redefine the #{name} method as it's required for safe HTML output."
|
10
|
-
end
|
11
|
-
|
12
|
-
super
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|