phlex-rails 0.9.0 → 0.10.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/CHANGELOG.md +19 -0
- data/Gemfile +2 -2
- data/lib/phlex/rails/sgml/overrides.rb +13 -2
- data/lib/phlex/rails/streaming.rb +24 -0
- data/lib/phlex/rails/unbuffered_overrides.rb +5 -1
- data/lib/phlex/rails/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 555800cbdaf17b6f8b17c861a26a3d3db5d189dc85ac2bb8e4a91ee01a3451a5
|
4
|
+
data.tar.gz: e6f95ee6e6ed074cb90ed8b5761fca2e5885879a6237e53287c9d19a0f7c3dc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ebedcdc21e1b898181068e2d71b15c8679c00cb66fc3f923fac36151a37fce36ad2486d7e561e6d9af8de82ea1c975d37e72b40bb01ac00a51a2e3ed2a770f1
|
7
|
+
data.tar.gz: d3f0a529298f5ae7ce3c1b1628488b076a596bef03225a158baa54a80fd28282072c8d88344d5c0c21ff3071d7023d9765a3545dace66bce7f7ca4c54d8f7624
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,19 @@
|
|
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
|
+
## 0.10.0
|
6
|
+
|
7
|
+
Added
|
8
|
+
|
9
|
+
- You can now render procs and lambdas and enumerables of renderables.
|
10
|
+
- Experimental streaming interface
|
11
|
+
|
12
|
+
Fixed
|
13
|
+
|
14
|
+
- Escaped ERB captures
|
15
|
+
- Use buffered component unless renderin in a template
|
16
|
+
|
17
|
+
***
|
18
|
+
|
19
|
+
Before this changelog was introduced, changes were logged in the [release notes](https://github.com/phlex-ruby/phlex/releases).
|
data/Gemfile
CHANGED
@@ -5,8 +5,8 @@ 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"
|
@@ -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,7 @@ module Phlex
|
|
60
60
|
super&.html_safe
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
63
|
+
def __text__(content)
|
64
64
|
case content
|
65
65
|
when ActiveSupport::SafeBuffer
|
66
66
|
@_context.target << content
|
@@ -69,6 +69,17 @@ module Phlex
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
# @api experimental
|
73
|
+
def await(task)
|
74
|
+
if task.is_a?(ActiveRecord::Relation)
|
75
|
+
flush unless task.loaded?
|
76
|
+
|
77
|
+
task
|
78
|
+
else
|
79
|
+
super
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
72
83
|
# Trick ViewComponent into thinking we're a ViewComponent to fix rendering output
|
73
84
|
def set_original_view_context(view_context)
|
74
85
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api experimental
|
4
|
+
module Phlex::Rails::Streaming
|
5
|
+
private def stream(view)
|
6
|
+
headers.delete("Content-Length")
|
7
|
+
|
8
|
+
headers["X-Accel-Buffering"] = "no"
|
9
|
+
headers["Cache-Control"] = "no-cache"
|
10
|
+
headers["Content-Type"] = "text/html; charset=utf-8"
|
11
|
+
headers["Last-Modified"] = Time.zone.now.ctime.to_s
|
12
|
+
|
13
|
+
response.status = 200
|
14
|
+
|
15
|
+
self.response_body = Enumerator.new do |buffer|
|
16
|
+
view.call(buffer, view_context: view_context)
|
17
|
+
rescue => e
|
18
|
+
buffer << %('">)
|
19
|
+
buffer << view_context.javascript_tag(nonce: true) { %(window.location = "/500.html").html_safe }
|
20
|
+
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -8,7 +8,11 @@ module Phlex::Rails::UnbufferedOverrides
|
|
8
8
|
@object.capture do
|
9
9
|
if b
|
10
10
|
@object.public_send(name, *a, **k) do |*aa|
|
11
|
-
|
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
|
12
16
|
end
|
13
17
|
else
|
14
18
|
@object.public_send(name, *a, **k)
|
data/lib/phlex/rails/version.rb
CHANGED
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.10.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-18 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:
|
19
|
+
version: 1.7.0
|
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:
|
26
|
+
version: 1.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- ".rubocop.yml"
|
70
70
|
- ".ruby-version"
|
71
71
|
- Appraisals
|
72
|
+
- CHANGELOG.md
|
72
73
|
- CODE_OF_CONDUCT.md
|
73
74
|
- CONTRIBUTING.md
|
74
75
|
- Gemfile
|
@@ -113,6 +114,7 @@ files:
|
|
113
114
|
- lib/phlex/rails/layout.rb
|
114
115
|
- lib/phlex/rails/sgml/class_methods.rb
|
115
116
|
- lib/phlex/rails/sgml/overrides.rb
|
117
|
+
- lib/phlex/rails/streaming.rb
|
116
118
|
- lib/phlex/rails/unbuffered_overrides.rb
|
117
119
|
- lib/phlex/rails/version.rb
|
118
120
|
- lib/phlex/testing/rails/view_helper.rb
|
@@ -122,8 +124,8 @@ licenses:
|
|
122
124
|
- MIT
|
123
125
|
metadata:
|
124
126
|
homepage_uri: https://www.phlex.fun
|
125
|
-
source_code_uri: https://github.com/
|
126
|
-
changelog_uri: https://github.com/
|
127
|
+
source_code_uri: https://github.com/phlex-ruby/phlex-rails
|
128
|
+
changelog_uri: https://github.com/phlex-ruby/phlex-rails/blob/main/CHANGELOG.md
|
127
129
|
funding_uri: https://github.com/sponsors/joeldrapper
|
128
130
|
rubygems_mfa_required: 'true'
|
129
131
|
post_install_message:
|