phlex-rails 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +3 -2
- data/lib/phlex/rails/buffered.rb +1 -0
- data/lib/phlex/rails/buffered_checkbox_builder.rb +1 -0
- data/lib/phlex/rails/buffered_form_builder.rb +1 -0
- data/lib/phlex/rails/buffered_label_builder.rb +1 -0
- data/lib/phlex/rails/buffered_radio_button_builder.rb +1 -0
- data/lib/phlex/rails/engine.rb +1 -0
- data/lib/phlex/rails/form.rb +1 -0
- data/lib/phlex/rails/helpers.rb +8 -0
- data/lib/phlex/rails/html/format.rb +1 -0
- data/lib/phlex/rails/layout.rb +1 -0
- data/lib/phlex/rails/sgml/overrides.rb +15 -2
- data/lib/phlex/rails/streaming.rb +26 -0
- data/lib/phlex/rails/unbuffered_overrides.rb +6 -1
- data/lib/phlex/rails/version.rb +1 -1
- data/lib/phlex/rails.rb +2 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b847ffd983ba4161668179eb395ccbfd50ee216892ffb7124bdacaa584a9e0a
|
4
|
+
data.tar.gz: e34aa3c4e6053b913f09f325ce11e16e6152afed5fecd18857a3ee634a735034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e955615cd2b7ac990742dd35028d524f74f8f05f0799ede53f793435344d1b3c7db6b99c87fb2f3fedef50f016f53d7f3cf32070ab7894be1b86c734b93cca76
|
7
|
+
data.tar.gz: 675126fe1bc74b22ee7ec284f0048ca4051a4fb3ea863fe916c8c48c745ca1ea431ed84569fda5d6b9ce046a58fd67f3b11f3e78bab25f4496074fc7e55d8e8a
|
data/.rubocop.yml
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--private --hide-api private --markup markdown --exclude lib/generators
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
4
|
+
|
5
|
+
## [1.0.0] 2023-04-19
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Added an adapter for the pluralize view helper.
|
10
|
+
|
11
|
+
## 0.10.0
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- You can now render procs and lambdas and enumerables of renderables.
|
16
|
+
- Experimental streaming interface
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Escaped ERB captures
|
21
|
+
- Use buffered component unless renderin in a template
|
22
|
+
|
23
|
+
***
|
24
|
+
|
25
|
+
Before this changelog was introduced, changes were logged in the [release notes](https://github.com/phlex-ruby/phlex/releases).
|
data/Gemfile
CHANGED
@@ -5,11 +5,12 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
5
|
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem "phlex", github: "
|
9
|
-
gem "phlex-testing-capybara", github: "
|
8
|
+
gem "phlex", github: "phlex-ruby/phlex"
|
9
|
+
gem "phlex-testing-capybara", github: "phlex-ruby/phlex-testing-capybara"
|
10
10
|
gem "rspec-rails"
|
11
11
|
gem "combustion"
|
12
12
|
gem "rubocop"
|
13
13
|
gem "solargraph"
|
14
14
|
gem "view_component"
|
15
15
|
gem "appraisal", github: "excid3/appraisal", branch: "fix-bundle-env"
|
16
|
+
gem "yard"
|
data/lib/phlex/rails/buffered.rb
CHANGED
data/lib/phlex/rails/engine.rb
CHANGED
data/lib/phlex/rails/form.rb
CHANGED
data/lib/phlex/rails/helpers.rb
CHANGED
@@ -883,6 +883,14 @@ module Phlex::Rails::Helpers
|
|
883
883
|
define_output_helper :phone_field_tag
|
884
884
|
end
|
885
885
|
|
886
|
+
module Pluralize
|
887
|
+
extend Phlex::Rails::HelperMacros
|
888
|
+
|
889
|
+
# @!method pluralize(...)
|
890
|
+
# @return [String]
|
891
|
+
define_value_helper :pluralize
|
892
|
+
end
|
893
|
+
|
886
894
|
module PreloadLinkTag
|
887
895
|
extend Phlex::Rails::HelperMacros
|
888
896
|
|
data/lib/phlex/rails/layout.rb
CHANGED
@@ -34,7 +34,7 @@ module Phlex
|
|
34
34
|
call(view_context: view_context) do |*args|
|
35
35
|
original_length = @_context.target.length
|
36
36
|
|
37
|
-
if args.length == 1 && Phlex::SGML === args[0]
|
37
|
+
if args.length == 1 && Phlex::SGML === args[0] && !block.source_location&.[](0)&.end_with?(".rb")
|
38
38
|
output = view_context.capture(
|
39
39
|
args[0].unbuffered, &block
|
40
40
|
)
|
@@ -60,7 +60,8 @@ module Phlex
|
|
60
60
|
super&.html_safe
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
# @api private
|
64
|
+
def __text__(content)
|
64
65
|
case content
|
65
66
|
when ActiveSupport::SafeBuffer
|
66
67
|
@_context.target << content
|
@@ -69,7 +70,19 @@ module Phlex
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
73
|
+
# @api private
|
74
|
+
def await(task)
|
75
|
+
if task.is_a?(ActiveRecord::Relation)
|
76
|
+
flush unless task.loaded?
|
77
|
+
|
78
|
+
task
|
79
|
+
else
|
80
|
+
super
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
72
84
|
# Trick ViewComponent into thinking we're a ViewComponent to fix rendering output
|
85
|
+
# @api private
|
73
86
|
def set_original_view_context(view_context)
|
74
87
|
end
|
75
88
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
module Phlex::Rails::Streaming
|
5
|
+
private
|
6
|
+
|
7
|
+
def stream(view)
|
8
|
+
headers.delete("Content-Length")
|
9
|
+
|
10
|
+
headers["X-Accel-Buffering"] = "no"
|
11
|
+
headers["Cache-Control"] = "no-cache"
|
12
|
+
headers["Content-Type"] = "text/html; charset=utf-8"
|
13
|
+
headers["Last-Modified"] = Time.zone.now.ctime.to_s
|
14
|
+
|
15
|
+
response.status = 200
|
16
|
+
|
17
|
+
self.response_body = Enumerator.new do |buffer|
|
18
|
+
view.call(buffer, view_context: view_context)
|
19
|
+
rescue => e
|
20
|
+
buffer << %('">)
|
21
|
+
buffer << view_context.javascript_tag(nonce: true) { %(window.location = "/500.html").html_safe }
|
22
|
+
|
23
|
+
raise e
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# @api private
|
3
4
|
module Phlex::Rails::UnbufferedOverrides
|
4
5
|
def method_missing(name, *args, **kwargs, &block)
|
5
6
|
if @object.respond_to?(name)
|
@@ -8,7 +9,11 @@ module Phlex::Rails::UnbufferedOverrides
|
|
8
9
|
@object.capture do
|
9
10
|
if b
|
10
11
|
@object.public_send(name, *a, **k) do |*aa|
|
11
|
-
|
12
|
+
if aa.length == 1 && aa[0].is_a?(Phlex::SGML)
|
13
|
+
@object.helpers.capture(aa[0].unbuffered, &b)
|
14
|
+
else
|
15
|
+
@object.helpers.capture(*aa, &b)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
else
|
14
19
|
@object.public_send(name, *a, **k)
|
data/lib/phlex/rails/version.rb
CHANGED
data/lib/phlex/rails.rb
CHANGED
@@ -22,11 +22,13 @@ module Phlex
|
|
22
22
|
prepend Phlex::Rails::SGML::Overrides
|
23
23
|
end
|
24
24
|
|
25
|
+
# @api private
|
25
26
|
class HTML
|
26
27
|
extend Phlex::Rails::HTML::Format
|
27
28
|
include Phlex::Rails::HTML::Format
|
28
29
|
end
|
29
30
|
|
31
|
+
# @api private
|
30
32
|
class Unbuffered
|
31
33
|
prepend ::Phlex::Rails::UnbufferedOverrides
|
32
34
|
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: 1.0.0
|
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-04-19 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.7'
|
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.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,7 +68,9 @@ files:
|
|
68
68
|
- ".editorconfig"
|
69
69
|
- ".rubocop.yml"
|
70
70
|
- ".ruby-version"
|
71
|
+
- ".yardopts"
|
71
72
|
- Appraisals
|
73
|
+
- CHANGELOG.md
|
72
74
|
- CODE_OF_CONDUCT.md
|
73
75
|
- CONTRIBUTING.md
|
74
76
|
- Gemfile
|
@@ -113,6 +115,7 @@ files:
|
|
113
115
|
- lib/phlex/rails/layout.rb
|
114
116
|
- lib/phlex/rails/sgml/class_methods.rb
|
115
117
|
- lib/phlex/rails/sgml/overrides.rb
|
118
|
+
- lib/phlex/rails/streaming.rb
|
116
119
|
- lib/phlex/rails/unbuffered_overrides.rb
|
117
120
|
- lib/phlex/rails/version.rb
|
118
121
|
- lib/phlex/testing/rails/view_helper.rb
|
@@ -122,8 +125,8 @@ licenses:
|
|
122
125
|
- MIT
|
123
126
|
metadata:
|
124
127
|
homepage_uri: https://www.phlex.fun
|
125
|
-
source_code_uri: https://github.com/
|
126
|
-
changelog_uri: https://github.com/
|
128
|
+
source_code_uri: https://github.com/phlex-ruby/phlex-rails
|
129
|
+
changelog_uri: https://github.com/phlex-ruby/phlex-rails/blob/main/CHANGELOG.md
|
127
130
|
funding_uri: https://github.com/sponsors/joeldrapper
|
128
131
|
rubygems_mfa_required: 'true'
|
129
132
|
post_install_message:
|