phlex 2.4.0.beta2 → 2.4.0
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 +4 -4
- data/lib/phlex/compiler/method_compiler.rb +1 -1
- data/lib/phlex/compiler.rb +0 -2
- data/lib/phlex/fifo.rb +1 -1
- data/lib/phlex/kit.rb +2 -2
- data/lib/phlex/sgml/attributes.rb +5 -1
- data/lib/phlex/sgml.rb +3 -47
- data/lib/phlex/version.rb +1 -1
- data/lib/ruby_lsp/phlex/addon.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7204ba8933eeeba6ac827d6a8f965f8a69a5d63245538a882f579881a1a4f3a
|
|
4
|
+
data.tar.gz: c0d11845eb37d6a14cd6c750972a7d898a63ba7062ddcf14f2e024e5785c20fb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33797f2a30f72abc79d5161e4d3006e38023450c0b4eee03018c19e545307c8344e4e085aeabd590184550ec1f1505e6681e943e1af2ab1bf5faf7f0392abcc1
|
|
7
|
+
data.tar.gz: 6ffe9a663d9be2d87d73992640c803107f26671598e058c843db8786678eee53bab16605e046af350ec0c6c9c0f5c5a5e7fe2860402f43da9727e3d54eee5e7b
|
|
@@ -462,7 +462,7 @@ module Phlex::Compiler
|
|
|
462
462
|
when Refract::AssocNode
|
|
463
463
|
(Refract::StringNode === value.key || Refract::SymbolNode === value.key) && static_attribute_value_literal?(value.value)
|
|
464
464
|
when Refract::CallNode
|
|
465
|
-
if value in { receiver: Prism::ConstantReadNode[name: :Set]| Prism::ConstantPathNode[name: :Set, parent: nil], name: :[] }
|
|
465
|
+
if value in { receiver: Prism::ConstantReadNode[name: :Set] | Prism::ConstantPathNode[name: :Set, parent: nil], name: :[] }
|
|
466
466
|
value.arguments.arguments.all? { |n| static_token_value_literal?(n) }
|
|
467
467
|
else
|
|
468
468
|
false
|
data/lib/phlex/compiler.rb
CHANGED
data/lib/phlex/fifo.rb
CHANGED
data/lib/phlex/kit.rb
CHANGED
|
@@ -63,8 +63,8 @@ module Phlex::Kit
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
define_singleton_method(name) do |*args, **kwargs, &block|
|
|
66
|
-
component
|
|
67
|
-
if
|
|
66
|
+
component = Thread.current[:__phlex_component__]
|
|
67
|
+
if component
|
|
68
68
|
component.instance_exec do
|
|
69
69
|
constant = me.const_get(name)
|
|
70
70
|
render(constant.new(*args, **kwargs), &block)
|
|
@@ -53,7 +53,11 @@ module Phlex::SGML::Attributes
|
|
|
53
53
|
when Phlex::SGML::SafeObject
|
|
54
54
|
v.to_s.gsub('"', """)
|
|
55
55
|
else
|
|
56
|
-
|
|
56
|
+
if v.respond_to?(:to_h)
|
|
57
|
+
generate_nested_attributes(v.to_h, "#{name}-", buffer)
|
|
58
|
+
else
|
|
59
|
+
raise Phlex::ArgumentError.new("Invalid attribute value for #{k}: #{v.inspect}.")
|
|
60
|
+
end
|
|
57
61
|
end
|
|
58
62
|
|
|
59
63
|
lower_name = name.downcase
|
data/lib/phlex/sgml.rb
CHANGED
|
@@ -2,17 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
# **Standard Generalized Markup Language** for behaviour common to {HTML} and {SVG}.
|
|
4
4
|
class Phlex::SGML
|
|
5
|
-
ERBCompiler = ERB::Compiler.new("<>").tap do |compiler|
|
|
6
|
-
compiler.pre_cmd = [""]
|
|
7
|
-
compiler.put_cmd = "@_state.buffer.<<"
|
|
8
|
-
compiler.insert_cmd = "__implicit_output__"
|
|
9
|
-
compiler.post_cmd = ["nil"]
|
|
10
|
-
|
|
11
|
-
def compiler.add_insert_cmd(out, content)
|
|
12
|
-
out.push("#{@insert_cmd}((#{content}))")
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
5
|
include Phlex::Helpers
|
|
17
6
|
|
|
18
7
|
class << self
|
|
@@ -32,40 +21,6 @@ class Phlex::SGML
|
|
|
32
21
|
super
|
|
33
22
|
end
|
|
34
23
|
end
|
|
35
|
-
|
|
36
|
-
def erb(method_name, erb = nil, locals: nil, &block)
|
|
37
|
-
loc = caller_locations(1, 1)[0]
|
|
38
|
-
path = loc.path.delete_suffix(".rb")
|
|
39
|
-
file = loc.path
|
|
40
|
-
line = loc.lineno - 1
|
|
41
|
-
|
|
42
|
-
unless erb
|
|
43
|
-
method_path = "#{path}/#{method_name}.html.erb"
|
|
44
|
-
sidecar_path = "#{path}.html.erb"
|
|
45
|
-
|
|
46
|
-
if File.exist?(method_path)
|
|
47
|
-
erb = File.read(method_path)
|
|
48
|
-
file = method_path
|
|
49
|
-
line = 1
|
|
50
|
-
elsif method_name == :view_template && File.exist?(sidecar_path)
|
|
51
|
-
erb = File.read(sidecar_path)
|
|
52
|
-
file = sidecar_path
|
|
53
|
-
line = 1
|
|
54
|
-
else
|
|
55
|
-
raise Phlex::RuntimeError.new(<<~MESSAGE)
|
|
56
|
-
No ERB template found for #{method_name}
|
|
57
|
-
MESSAGE
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
code, _enc = ERBCompiler.compile(erb)
|
|
62
|
-
|
|
63
|
-
class_eval(<<~RUBY, file, line)
|
|
64
|
-
def #{method_name} #{locals}
|
|
65
|
-
#{code}
|
|
66
|
-
end
|
|
67
|
-
RUBY
|
|
68
|
-
end
|
|
69
24
|
end
|
|
70
25
|
|
|
71
26
|
def view_template
|
|
@@ -105,7 +60,8 @@ class Phlex::SGML
|
|
|
105
60
|
|
|
106
61
|
block ||= @_content_block
|
|
107
62
|
|
|
108
|
-
Thread.current[:__phlex_component__]
|
|
63
|
+
previous_phlex_component = Thread.current[:__phlex_component__]
|
|
64
|
+
Thread.current[:__phlex_component__] = self
|
|
109
65
|
|
|
110
66
|
state.around_render(self) do
|
|
111
67
|
before_template(&block)
|
|
@@ -127,7 +83,7 @@ class Phlex::SGML
|
|
|
127
83
|
after_template(&block)
|
|
128
84
|
end
|
|
129
85
|
ensure
|
|
130
|
-
Thread.current[:__phlex_component__] =
|
|
86
|
+
Thread.current[:__phlex_component__] = previous_phlex_component
|
|
131
87
|
end
|
|
132
88
|
|
|
133
89
|
def context
|
data/lib/phlex/version.rb
CHANGED
data/lib/ruby_lsp/phlex/addon.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phlex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.4.0
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joel Drapper
|
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
99
99
|
- !ruby/object:Gem::Version
|
|
100
100
|
version: '0'
|
|
101
101
|
requirements: []
|
|
102
|
-
rubygems_version:
|
|
102
|
+
rubygems_version: 4.0.3
|
|
103
103
|
specification_version: 4
|
|
104
104
|
summary: Object-oriented views in Ruby.
|
|
105
105
|
test_files: []
|