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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64bd1c0569d8a687689b1eec091acff484e3c3c7db388f80ddc1cb059881c680
4
- data.tar.gz: 282af2d851aaef5e1266519b59ba5ade1360cd13666d629b4109441f16abb6f6
3
+ metadata.gz: 555800cbdaf17b6f8b17c861a26a3d3db5d189dc85ac2bb8e4a91ee01a3451a5
4
+ data.tar.gz: e6f95ee6e6ed074cb90ed8b5761fca2e5885879a6237e53287c9d19a0f7c3dc5
5
5
  SHA512:
6
- metadata.gz: e9f65f079a1ec7372692767beb7f7f1f70dac50f4429f429aa0085bbfefcd40675e2933985d728ed2354fb90983d86a707d1f5432c3333f72f843032086c7924
7
- data.tar.gz: 7e5f5fe2316c5db3ae8757a67517856ffdebf4f5b03467d17a712eb6c571486f402ceeb993cd1ceba31c3a7cfef37aa104ed297123be43fb30cb2af790775530
6
+ metadata.gz: 5ebedcdc21e1b898181068e2d71b15c8679c00cb66fc3f923fac36151a37fce36ad2486d7e561e6d9af8de82ea1c975d37e72b40bb01ac00a51a2e3ed2a770f1
7
+ data.tar.gz: d3f0a529298f5ae7ce3c1b1628488b076a596bef03225a158baa54a80fd28282072c8d88344d5c0c21ff3071d7023d9765a3545dace66bce7f7ca4c54d8f7624
data/.rubocop.yml CHANGED
@@ -10,3 +10,6 @@ AllCops:
10
10
 
11
11
  Style/MissingRespondToMissing:
12
12
  Enabled: false
13
+
14
+ Style/RescueStandardError:
15
+ Enabled: false
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: "joeldrapper/phlex"
9
- gem "phlex-testing-capybara", github: "joeldrapper/phlex-testing-capybara"
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 plain(content)
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
- @object.helpers.capture(*aa, &b)
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phlex
4
4
  module Rails
5
- VERSION = "0.9.0"
5
+ VERSION = "0.10.0"
6
6
  end
7
7
  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.9.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-03-08 00:00:00.000000000 Z
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: '1.6'
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: '1.6'
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/joeldrapper/phlex
126
- changelog_uri: https://github.com/joeldrapper/phlex/releases
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: