phlex 1.10.2 → 1.11.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: cba68a9129cc5ece4a9fc967617121682b75409634a7d125f510ace4348cd77b
4
- data.tar.gz: 434168d192738d11c66d0ea9291dd7f4cc96b8b122f02e38d85f2a9f7afaad01
3
+ metadata.gz: 91e06f170cfccd6ef24d00ef34643293d36c9df7540ffb3fe482577c4a115898
4
+ data.tar.gz: 9eb38a0b368e1543789252f6ba8cb80df204b73fc81d413fc47b758adba191bc
5
5
  SHA512:
6
- metadata.gz: 4cbcbb20ab4093f9877bac0a03a3686aaceffc883984a7fa25f93c1862988257afc9e71af93772c67760794bcbdfab6fb9a995f71ed492fbbd436b8311f8961c
7
- data.tar.gz: 07f4e11850deef3538c1296693dd9897eea0d7a26eefb3757bd1afbd89b6c9f486b974e0fdfb7f31cd602fe5e776560a5964f679b62ae72b9a0ba601448bd055
6
+ metadata.gz: 4f2587dff9519706d7ec91c2745da7570c74a097b0282c0462504a54cc296312f1aee386a6645f1df5e7f503e1398df72681d345d18e5866f13a4dfcd4c4db1c
7
+ data.tar.gz: 3de0960cc4510e025620308ed8ae6c0b5594d3ee8a153b11c5c3eabdc74d3aa94193717f9a6fbc47fa378e8b7bbcd171a35bcfa3f486e66800bffd8da01bc033
data/lib/phlex/kit.rb CHANGED
@@ -1,31 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex::Kit
4
- def self.extended(mod)
5
- warn "⚠️ [WARNING] Phlex::Kit is experimental and may be removed from future versions of Phlex."
6
- super
4
+ module LazyLoader
5
+ def method_missing(name, *args, **kwargs, &block)
6
+ if name[0] == name[0].upcase && __phlex_kit_constants__.include?(name) && __get_phlex_kit_constant__(name) && methods.include?(name)
7
+ public_send(name, *args, **kwargs, &block)
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+ def respond_to_missing?(name, include_private = false)
14
+ if name[0] == name[0].upcase && __phlex_kit_constants__.include?(name) && __get_phlex_kit_constant__(name) && methods.include?(name)
15
+ true
16
+ else
17
+ super
18
+ end
19
+ end
7
20
  end
8
21
 
9
- # When a kit is included in a module, we need to load all of its components.
10
- def included(mod)
11
- constants.each { |c| const_get(c) if autoload?(c) }
12
- super
22
+ include LazyLoader
23
+
24
+ def self.extended(mod)
25
+ mod.include(LazyLoader)
26
+ mod.define_method(:__phlex_kit_constants__) { mod.__phlex_kit_constants__ }
27
+ mod.define_method(:__get_phlex_kit_constant__) { |name| mod.__get_phlex_kit_constant__(name) }
13
28
  end
14
29
 
15
- def method_missing(name, *args, **kwargs, &block)
16
- if name[0] == name[0].upcase && constants.include?(name) && const_get(name) && methods.include?(name)
17
- public_send(name, *args, **kwargs, &block)
18
- else
19
- super
20
- end
30
+ def __phlex_kit_constants__
31
+ constants
21
32
  end
22
33
 
23
- def respond_to_missing?(name, include_private = false)
24
- if name[0] == name[0].upcase && constants.include?(name) && const_get(name) && methods.include?(name)
25
- true
26
- else
27
- super
28
- end
34
+ def __get_phlex_kit_constant__(name)
35
+ const_get(name)
29
36
  end
30
37
 
31
38
  def const_added(name)
data/lib/phlex/sgml.rb CHANGED
@@ -71,7 +71,7 @@ module Phlex
71
71
 
72
72
  def self.method_added(method_name)
73
73
  if method_name == :template
74
- Kernel.warn "⚠️ [DEPRECATION] Defining the `template` method on a Phlex component will not be supported in Phlex 2.0. Please rename the method to `view_template` instead."
74
+ Kernel.warn "⚠️ [DEPRECATION] Defining the `template` method on a Phlex component will not be supported in Phlex 2.0. Please rename `#{name}#template` to `#{name}#view_template` instead."
75
75
  end
76
76
  end
77
77
 
@@ -105,6 +105,11 @@ module Phlex
105
105
  @_context = context
106
106
  @_view_context = view_context
107
107
  @_parent = parent
108
+ if @_rendered
109
+ warn "⚠️ [WARNING] You are rendering a component #{self.class.name} twice. This is not supported in Phlex 2.0."
110
+ end
111
+ @_rendered = true
112
+
108
113
  if fragments
109
114
  warn "⚠️ [WARNING] Selective Rendering is experimental, incomplete, and may change in future versions."
110
115
  @_context.target_fragments(fragments)
@@ -216,10 +221,14 @@ module Phlex
216
221
  # Capture a block of output as a String.
217
222
  # @note This only works if the block's receiver is the current component or the block returns a String.
218
223
  # @return [String]
219
- def capture(&block)
224
+ def capture(*args, &block)
220
225
  return "" unless block
221
226
 
222
- @_context.capturing_into(+"") { yield_content(&block) }
227
+ if args.length > 0
228
+ @_context.capturing_into(+"") { yield_content_with_args(*args, &block) }
229
+ else
230
+ @_context.capturing_into(+"") { yield_content(&block) }
231
+ end
223
232
  end
224
233
 
225
234
  private
@@ -431,6 +440,10 @@ module Phlex
431
440
  raise ArgumentError, "Unsafe attribute name detected: #{k}."
432
441
  end
433
442
 
443
+ if lower_name.to_sym == :id && k != :id
444
+ warn "⚠️ [WARNING] Starting 2.0 Phlex will raise on non lowercase or string :id attribute."
445
+ end
446
+
434
447
  case v
435
448
  when true
436
449
  buffer << " " << name
data/lib/phlex/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex
4
- VERSION = "1.10.2"
4
+ VERSION = "1.11.0"
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: 1.10.2
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-07-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A high-performance view framework optimised for fun.
14
14
  email:
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
65
- rubygems_version: 3.5.3
65
+ rubygems_version: 3.5.13
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: A fun framework for building views in Ruby.