phlex 2.0.0 → 2.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c026ac28ef7bc6f31e884f1c49c67dfc4a27076fc0ea7a665c8a96c0b3dcaa3
4
- data.tar.gz: 0f3f6e499197804439e4b10ce59b373ab50f205b44401a8138d34fac5aad33c5
3
+ metadata.gz: e84eae72307b1f6e6bf3337cd74d1208d3c2fb58f11e7c08eaf6dd0272fbc702
4
+ data.tar.gz: a2edd58bd5a1c5185bf9b4222cb0f674fcd488243b4a33c140c92577cd74cbb8
5
5
  SHA512:
6
- metadata.gz: cf1c198dd1adae024f45a146674e8f48d9a4ed3a4d9b01f192991e5d80d2288fe09579795988e93d5e03690b2928cf71f3ba96fb918b1ab5995170ffedaa6b48
7
- data.tar.gz: d2e7cab80ad487d991593856905581dfad3c293e834d2d2684d292df872f668774a5ab418c929865b171bd4a6932483fa24bdc7606be35ab40ddb073e8d1d0e6
6
+ metadata.gz: 22c542f19b5121666bca2f3bf661ff05488c21d5b593578f704dbe9f69643d48b839deddd9898214638a21dc7fb9de56dcb750f7401082710a13a5544668a643
7
+ data.tar.gz: a81c55fb957fa70907fac519b08c072521701908385227f93284219de34e0338a48276faff36ef54ba60d552511a579a734725fcbfea7b6d302edbaaf9e94c54
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Phlex lets you build object-oriented web views in pure Ruby.
4
4
 
5
- - [v1 Stable Docs](https://www.phlex.fun)
6
- - [v2 Beta Docs](https://beta.phlex.fun)
5
+ - [v2 Docs](https://www.phlex.fun)
6
+ - [v1 Docs](https://v1.phlex.fun)
7
7
 
8
8
  ## Versioning and Maintenance
9
9
 
data/lib/phlex/sgml.rb CHANGED
@@ -56,8 +56,6 @@ class Phlex::SGML
56
56
  end
57
57
 
58
58
  def internal_call(parent: nil, state: nil, &block)
59
- return "" unless render?
60
-
61
59
  if @_state
62
60
  raise Phlex::DoubleRenderError.new(
63
61
  "You can't render a #{self.class.name} more than once."
@@ -66,6 +64,8 @@ class Phlex::SGML
66
64
 
67
65
  @_state = state
68
66
 
67
+ return "" unless render?
68
+
69
69
  block ||= @_content_block
70
70
 
71
71
  Thread.current[:__phlex_component__] = [self, Fiber.current.object_id].freeze
@@ -94,7 +94,19 @@ class Phlex::SGML
94
94
  end
95
95
 
96
96
  def context
97
- @_state.user_context
97
+ if rendering?
98
+ @_state.user_context
99
+ else
100
+ raise Phlex::ArgumentError.new(<<~MESSAGE)
101
+ You can’t access the context before the component has started rendering.
102
+ MESSAGE
103
+ end
104
+ end
105
+
106
+ # Returns `false` before rendering and `true` once the component has started rendering.
107
+ # It will not reset back to false after rendering.
108
+ def rendering?
109
+ !!@_state
98
110
  end
99
111
 
100
112
  # Output plain text.
data/lib/phlex/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  - Will Cosgrove
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-14 00:00:00.000000000 Z
11
+ date: 2025-02-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build HTML & SVG view components with Ruby classes.
14
14
  email: