phlex 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of phlex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.editorconfig +8 -0
- data/.rubocop.yml +21 -5
- data/Gemfile +26 -12
- data/Procfile.dev +3 -0
- data/README.md +1 -1
- data/Rakefile +3 -5
- data/SECURITY.md +1 -1
- data/bench.rb +7 -0
- data/config/sus.rb +15 -0
- data/docs/assets/application.css +6 -0
- data/docs/build.rb +17 -10
- data/docs/components/callout.rb +1 -1
- data/docs/components/code_block.rb +2 -2
- data/docs/components/code_span.rb +9 -0
- data/docs/components/example.rb +5 -5
- data/docs/components/heading.rb +2 -2
- data/docs/components/layout.rb +62 -17
- data/docs/components/markdown.rb +14 -15
- data/docs/components/nav/item.rb +33 -0
- data/docs/components/nav.rb +6 -0
- data/docs/components/tabs/tab.rb +4 -2
- data/docs/components/tabs.rb +1 -1
- data/docs/components/title.rb +2 -2
- data/docs/page_builder.rb +3 -0
- data/docs/pages/application_page.rb +1 -1
- data/docs/pages/helpers.rb +97 -0
- data/docs/pages/index.rb +6 -17
- data/docs/pages/library/collections.rb +83 -0
- data/docs/pages/rails/getting_started.rb +53 -0
- data/docs/pages/rails/helpers.rb +55 -0
- data/docs/pages/rails/layouts.rb +61 -0
- data/docs/pages/rails/migrating.rb +37 -0
- data/docs/pages/rails/rendering_views.rb +35 -0
- data/docs/pages/templates.rb +53 -151
- data/docs/pages/testing/capybara.rb +48 -0
- data/docs/pages/testing/getting_started.rb +44 -0
- data/docs/pages/testing/nokogiri.rb +83 -0
- data/docs/pages/testing/rails.rb +17 -0
- data/docs/pages/translations.rb +81 -0
- data/docs/pages/views.rb +87 -78
- data/fixtures/compiler_test_helpers.rb +19 -0
- data/fixtures/content.rb +60 -0
- data/fixtures/dummy/app/components/comment_component.html.erb +14 -0
- data/fixtures/dummy/app/components/comment_component.rb +8 -0
- data/fixtures/dummy/app/components/reaction_component.html.erb +3 -0
- data/fixtures/dummy/app/components/reaction_component.rb +7 -0
- data/fixtures/dummy/app/controllers/comments_controller.rb +4 -0
- data/fixtures/dummy/app/views/application_view.rb +8 -0
- data/fixtures/dummy/app/views/articles/form.rb +3 -1
- data/fixtures/dummy/app/views/card.rb +4 -2
- data/fixtures/dummy/app/views/comments/comment.rb +25 -0
- data/fixtures/dummy/app/views/comments/index.html.erb +3 -0
- data/fixtures/dummy/app/views/comments/reaction.rb +17 -0
- data/fixtures/dummy/app/views/comments/show.html.erb +3 -0
- data/fixtures/dummy/app/views/heading.rb +1 -1
- data/fixtures/layout.rb +5 -5
- data/fixtures/page.rb +18 -24
- data/fixtures/{test_helper.rb → rails_helper.rb} +3 -7
- data/fixtures/standard_element.rb +87 -0
- data/fixtures/view_helper.rb +1 -1
- data/fixtures/void_element.rb +31 -0
- data/lib/generators/phlex/collection/USAGE +8 -0
- data/lib/generators/phlex/collection/collection_generator.rb +13 -0
- data/lib/generators/phlex/collection/templates/collection.rb.erb +16 -0
- data/lib/generators/phlex/controller/USAGE +10 -0
- data/lib/generators/phlex/controller/controller_generator.rb +54 -0
- data/lib/generators/phlex/controller/templates/controller.rb.erb +10 -0
- data/lib/generators/phlex/controller/templates/view.rb.erb +14 -0
- data/lib/generators/phlex/layout/USAGE +8 -0
- data/lib/generators/phlex/layout/layout_generator.rb +13 -0
- data/lib/generators/phlex/layout/templates/layout.rb.erb +31 -0
- data/lib/generators/phlex/page/USAGE +8 -0
- data/lib/generators/phlex/page/page_generator.rb +13 -0
- data/lib/generators/phlex/page/templates/page.rb.erb +13 -0
- data/lib/generators/phlex/table/USAGE +8 -0
- data/lib/generators/phlex/table/table_generator.rb +14 -0
- data/lib/generators/phlex/table/templates/table.rb.erb +11 -0
- data/lib/generators/phlex/view/templates/view.rb.erb +7 -1
- data/lib/generators/phlex/view/view_generator.rb +9 -1
- data/lib/install/phlex.rb +10 -1
- data/lib/phlex/block.rb +2 -4
- data/lib/phlex/buffered.rb +6 -8
- data/lib/phlex/callable.rb +9 -0
- data/lib/phlex/collection.rb +33 -0
- data/lib/phlex/compiler/elements.rb +49 -0
- data/lib/phlex/compiler/generators/content.rb +103 -0
- data/lib/phlex/compiler/generators/element.rb +61 -0
- data/lib/phlex/compiler/nodes/base.rb +19 -0
- data/lib/phlex/compiler/nodes/call.rb +9 -0
- data/lib/phlex/compiler/nodes/command.rb +13 -0
- data/lib/phlex/compiler/nodes/fcall.rb +18 -0
- data/lib/phlex/compiler/nodes/method_add_block.rb +33 -0
- data/lib/phlex/compiler/nodes/vcall.rb +9 -0
- data/lib/phlex/compiler/optimizer.rb +66 -0
- data/lib/phlex/compiler/visitors/base.rb +15 -0
- data/lib/phlex/compiler/visitors/file.rb +23 -11
- data/lib/phlex/compiler/visitors/stable_scope.rb +28 -0
- data/lib/phlex/compiler/visitors/statements.rb +36 -0
- data/lib/phlex/compiler/visitors/view.rb +19 -0
- data/lib/phlex/compiler/visitors/view_method.rb +59 -0
- data/lib/phlex/compiler.rb +23 -3
- data/lib/phlex/elements.rb +57 -0
- data/lib/phlex/engine.rb +0 -3
- data/lib/phlex/helpers.rb +59 -0
- data/lib/phlex/html/callbacks.rb +11 -0
- data/lib/phlex/html.rb +209 -54
- data/lib/phlex/markdown.rb +76 -0
- data/lib/phlex/rails/form.rb +67 -0
- data/lib/phlex/rails/helpers.rb +118 -0
- data/lib/phlex/rails/layout.rb +15 -0
- data/lib/phlex/rails.rb +10 -0
- data/lib/phlex/renderable.rb +9 -3
- data/lib/phlex/table.rb +104 -0
- data/lib/phlex/testing/capybara.rb +25 -0
- data/lib/phlex/testing/nokogiri.rb +24 -0
- data/lib/phlex/testing/rails.rb +19 -0
- data/lib/phlex/testing/view_helper.rb +15 -0
- data/lib/phlex/translation.rb +23 -0
- data/lib/phlex/turbo/frame.rb +21 -0
- data/lib/phlex/turbo/stream.rb +18 -0
- data/lib/phlex/version.rb +1 -1
- data/lib/phlex.rb +22 -24
- metadata +112 -15
- data/.rspec +0 -1
- data/fixtures/compilation/vcall.rb +0 -38
- data/lib/phlex/compiler/generators/standard_element.rb +0 -30
- data/lib/phlex/compiler/generators/void_element.rb +0 -29
- data/lib/phlex/compiler/optimizers/base_optimizer.rb +0 -34
- data/lib/phlex/compiler/optimizers/vcall.rb +0 -29
- data/lib/phlex/compiler/visitors/base_visitor.rb +0 -19
- data/lib/phlex/compiler/visitors/component.rb +0 -28
- data/lib/phlex/compiler/visitors/component_method.rb +0 -28
- data/lib/phlex/rails/tag_helpers.rb +0 -29
- data/lib/phlex/view.rb +0 -223
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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: 2022-
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hescape
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: syntax_tree
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '2.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: view_component
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.7'
|
41
69
|
description: A high-performance view framework optimised for developer happiness.
|
42
70
|
email:
|
43
71
|
- joel@drapper.me
|
@@ -46,42 +74,69 @@ extensions: []
|
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
48
76
|
- ".editorconfig"
|
49
|
-
- ".rspec"
|
50
77
|
- ".rubocop.yml"
|
51
78
|
- CODE_OF_CONDUCT.md
|
52
79
|
- CONTRIBUTING.md
|
53
80
|
- Gemfile
|
54
81
|
- LICENSE.txt
|
82
|
+
- Procfile.dev
|
55
83
|
- README.md
|
56
84
|
- Rakefile
|
57
85
|
- SECURITY.md
|
58
86
|
- bench.rb
|
59
87
|
- config.ru
|
88
|
+
- config/sus.rb
|
60
89
|
- docs/assets/application.css
|
61
90
|
- docs/assets/logo.png
|
62
91
|
- docs/build.rb
|
63
92
|
- docs/components/callout.rb
|
64
93
|
- docs/components/code_block.rb
|
94
|
+
- docs/components/code_span.rb
|
65
95
|
- docs/components/example.rb
|
66
96
|
- docs/components/heading.rb
|
67
97
|
- docs/components/layout.rb
|
68
98
|
- docs/components/markdown.rb
|
99
|
+
- docs/components/nav.rb
|
100
|
+
- docs/components/nav/item.rb
|
69
101
|
- docs/components/tabs.rb
|
70
102
|
- docs/components/tabs/tab.rb
|
71
103
|
- docs/components/title.rb
|
72
104
|
- docs/page_builder.rb
|
73
105
|
- docs/pages/application_page.rb
|
106
|
+
- docs/pages/helpers.rb
|
74
107
|
- docs/pages/index.rb
|
108
|
+
- docs/pages/library/collections.rb
|
109
|
+
- docs/pages/rails/getting_started.rb
|
110
|
+
- docs/pages/rails/helpers.rb
|
111
|
+
- docs/pages/rails/layouts.rb
|
112
|
+
- docs/pages/rails/migrating.rb
|
113
|
+
- docs/pages/rails/rendering_views.rb
|
75
114
|
- docs/pages/rails_integration.rb
|
76
115
|
- docs/pages/templates.rb
|
116
|
+
- docs/pages/testing/capybara.rb
|
117
|
+
- docs/pages/testing/getting_started.rb
|
118
|
+
- docs/pages/testing/nokogiri.rb
|
119
|
+
- docs/pages/testing/rails.rb
|
120
|
+
- docs/pages/translations.rb
|
77
121
|
- docs/pages/views.rb
|
78
|
-
- fixtures/
|
122
|
+
- fixtures/compiler_test_helpers.rb
|
123
|
+
- fixtures/content.rb
|
79
124
|
- fixtures/dummy/app/assets/config/manifest.js
|
125
|
+
- fixtures/dummy/app/components/comment_component.html.erb
|
126
|
+
- fixtures/dummy/app/components/comment_component.rb
|
127
|
+
- fixtures/dummy/app/components/reaction_component.html.erb
|
128
|
+
- fixtures/dummy/app/components/reaction_component.rb
|
80
129
|
- fixtures/dummy/app/controllers/articles_controller.rb
|
130
|
+
- fixtures/dummy/app/controllers/comments_controller.rb
|
131
|
+
- fixtures/dummy/app/views/application_view.rb
|
81
132
|
- fixtures/dummy/app/views/articles/form.rb
|
82
133
|
- fixtures/dummy/app/views/articles/index.html.erb
|
83
134
|
- fixtures/dummy/app/views/articles/new.html.erb
|
84
135
|
- fixtures/dummy/app/views/card.rb
|
136
|
+
- fixtures/dummy/app/views/comments/comment.rb
|
137
|
+
- fixtures/dummy/app/views/comments/index.html.erb
|
138
|
+
- fixtures/dummy/app/views/comments/reaction.rb
|
139
|
+
- fixtures/dummy/app/views/comments/show.html.erb
|
85
140
|
- fixtures/dummy/app/views/heading.rb
|
86
141
|
- fixtures/dummy/config/database.yml
|
87
142
|
- fixtures/dummy/config/routes.rb
|
@@ -91,8 +146,26 @@ files:
|
|
91
146
|
- fixtures/dummy/public/favicon.ico
|
92
147
|
- fixtures/layout.rb
|
93
148
|
- fixtures/page.rb
|
94
|
-
- fixtures/
|
149
|
+
- fixtures/rails_helper.rb
|
150
|
+
- fixtures/standard_element.rb
|
95
151
|
- fixtures/view_helper.rb
|
152
|
+
- fixtures/void_element.rb
|
153
|
+
- lib/generators/phlex/collection/USAGE
|
154
|
+
- lib/generators/phlex/collection/collection_generator.rb
|
155
|
+
- lib/generators/phlex/collection/templates/collection.rb.erb
|
156
|
+
- lib/generators/phlex/controller/USAGE
|
157
|
+
- lib/generators/phlex/controller/controller_generator.rb
|
158
|
+
- lib/generators/phlex/controller/templates/controller.rb.erb
|
159
|
+
- lib/generators/phlex/controller/templates/view.rb.erb
|
160
|
+
- lib/generators/phlex/layout/USAGE
|
161
|
+
- lib/generators/phlex/layout/layout_generator.rb
|
162
|
+
- lib/generators/phlex/layout/templates/layout.rb.erb
|
163
|
+
- lib/generators/phlex/page/USAGE
|
164
|
+
- lib/generators/phlex/page/page_generator.rb
|
165
|
+
- lib/generators/phlex/page/templates/page.rb.erb
|
166
|
+
- lib/generators/phlex/table/USAGE
|
167
|
+
- lib/generators/phlex/table/table_generator.rb
|
168
|
+
- lib/generators/phlex/table/templates/table.rb.erb
|
96
169
|
- lib/generators/phlex/view/USAGE
|
97
170
|
- lib/generators/phlex/view/templates/view.rb.erb
|
98
171
|
- lib/generators/phlex/view/view_generator.rb
|
@@ -101,23 +174,47 @@ files:
|
|
101
174
|
- lib/phlex.rb
|
102
175
|
- lib/phlex/block.rb
|
103
176
|
- lib/phlex/buffered.rb
|
177
|
+
- lib/phlex/callable.rb
|
178
|
+
- lib/phlex/collection.rb
|
104
179
|
- lib/phlex/compiler.rb
|
180
|
+
- lib/phlex/compiler/elements.rb
|
105
181
|
- lib/phlex/compiler/formatter.rb
|
106
|
-
- lib/phlex/compiler/generators/
|
107
|
-
- lib/phlex/compiler/generators/
|
108
|
-
- lib/phlex/compiler/
|
109
|
-
- lib/phlex/compiler/
|
110
|
-
- lib/phlex/compiler/
|
111
|
-
- lib/phlex/compiler/
|
112
|
-
- lib/phlex/compiler/
|
182
|
+
- lib/phlex/compiler/generators/content.rb
|
183
|
+
- lib/phlex/compiler/generators/element.rb
|
184
|
+
- lib/phlex/compiler/nodes/base.rb
|
185
|
+
- lib/phlex/compiler/nodes/call.rb
|
186
|
+
- lib/phlex/compiler/nodes/command.rb
|
187
|
+
- lib/phlex/compiler/nodes/fcall.rb
|
188
|
+
- lib/phlex/compiler/nodes/method_add_block.rb
|
189
|
+
- lib/phlex/compiler/nodes/vcall.rb
|
190
|
+
- lib/phlex/compiler/optimizer.rb
|
191
|
+
- lib/phlex/compiler/visitors/base.rb
|
113
192
|
- lib/phlex/compiler/visitors/file.rb
|
193
|
+
- lib/phlex/compiler/visitors/stable_scope.rb
|
194
|
+
- lib/phlex/compiler/visitors/statements.rb
|
195
|
+
- lib/phlex/compiler/visitors/view.rb
|
196
|
+
- lib/phlex/compiler/visitors/view_method.rb
|
114
197
|
- lib/phlex/configuration.rb
|
198
|
+
- lib/phlex/elements.rb
|
115
199
|
- lib/phlex/engine.rb
|
200
|
+
- lib/phlex/helpers.rb
|
116
201
|
- lib/phlex/html.rb
|
117
|
-
- lib/phlex/
|
202
|
+
- lib/phlex/html/callbacks.rb
|
203
|
+
- lib/phlex/markdown.rb
|
204
|
+
- lib/phlex/rails.rb
|
205
|
+
- lib/phlex/rails/form.rb
|
206
|
+
- lib/phlex/rails/helpers.rb
|
207
|
+
- lib/phlex/rails/layout.rb
|
118
208
|
- lib/phlex/renderable.rb
|
209
|
+
- lib/phlex/table.rb
|
210
|
+
- lib/phlex/testing/capybara.rb
|
211
|
+
- lib/phlex/testing/nokogiri.rb
|
212
|
+
- lib/phlex/testing/rails.rb
|
213
|
+
- lib/phlex/testing/view_helper.rb
|
214
|
+
- lib/phlex/translation.rb
|
215
|
+
- lib/phlex/turbo/frame.rb
|
216
|
+
- lib/phlex/turbo/stream.rb
|
119
217
|
- lib/phlex/version.rb
|
120
|
-
- lib/phlex/view.rb
|
121
218
|
- lib/tasks/phlex_tasks.rake
|
122
219
|
- package-lock.json
|
123
220
|
- package.json
|
@@ -148,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
245
|
- !ruby/object:Gem::Version
|
149
246
|
version: '0'
|
150
247
|
requirements: []
|
151
|
-
rubygems_version: 3.3.
|
248
|
+
rubygems_version: 3.3.25
|
152
249
|
signing_key:
|
153
250
|
specification_version: 4
|
154
251
|
summary: A framework for building views with a Ruby DSL.
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--require spec_helper
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Fixtures
|
4
|
-
module Compilation
|
5
|
-
module VCall
|
6
|
-
class WithStandardElement < Phlex::View
|
7
|
-
def template
|
8
|
-
div
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class WithVoidElement < Phlex::View
|
13
|
-
def template
|
14
|
-
img
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class WithAnotherMethodCall < Phlex::View
|
19
|
-
def template
|
20
|
-
article
|
21
|
-
some_other_method
|
22
|
-
article
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class WithRedefinedTagMethod < Phlex::View
|
27
|
-
def template
|
28
|
-
title
|
29
|
-
article
|
30
|
-
end
|
31
|
-
|
32
|
-
def title
|
33
|
-
h1
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
class Compiler
|
5
|
-
module Generators
|
6
|
-
class StandardElement
|
7
|
-
def initialize(formatter, method_name:, arguments: nil)
|
8
|
-
@formatter = formatter
|
9
|
-
@method_name = method_name
|
10
|
-
end
|
11
|
-
|
12
|
-
def call
|
13
|
-
@formatter.append do |f|
|
14
|
-
f.text "<"
|
15
|
-
f.text tag
|
16
|
-
f.text ">"
|
17
|
-
|
18
|
-
f.text "</"
|
19
|
-
f.text tag
|
20
|
-
f.text ">"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def tag
|
25
|
-
HTML::STANDARD_ELEMENTS[@method_name]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
class Compiler
|
5
|
-
module Generators
|
6
|
-
class VoidElement
|
7
|
-
def initialize(formatter, method_name:, arguments: nil)
|
8
|
-
@formatter = formatter
|
9
|
-
@method_name = method_name
|
10
|
-
@arguments = arguments
|
11
|
-
end
|
12
|
-
|
13
|
-
def call
|
14
|
-
@formatter.append do |f|
|
15
|
-
f.text "<"
|
16
|
-
f.text tag
|
17
|
-
f.text " />"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def tag
|
24
|
-
HTML::VOID_ELEMENTS[@method_name]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
class Compiler
|
5
|
-
module Optimizers
|
6
|
-
class BaseOptimizer
|
7
|
-
def initialize(node, compiler:)
|
8
|
-
@node = node
|
9
|
-
@compiler = compiler
|
10
|
-
end
|
11
|
-
|
12
|
-
def call
|
13
|
-
if standard_element?
|
14
|
-
@node.extend(self.class::StandardElement)
|
15
|
-
elsif void_element?
|
16
|
-
@node.extend(self.class::VoidElement)
|
17
|
-
else
|
18
|
-
false
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def standard_element?
|
25
|
-
HTML::STANDARD_ELEMENTS[name] && !@compiler.redefined?(name)
|
26
|
-
end
|
27
|
-
|
28
|
-
def void_element?
|
29
|
-
HTML::VOID_ELEMENTS[name] && !@compiler.redefined?(name)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
class Compiler
|
5
|
-
module Optimizers
|
6
|
-
class VCall < BaseOptimizer
|
7
|
-
module StandardElement
|
8
|
-
def format(formatter)
|
9
|
-
Generators::StandardElement.new(formatter,
|
10
|
-
method_name: value.value.to_sym).call
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module VoidElement
|
15
|
-
def format(formatter)
|
16
|
-
Generators::VoidElement.new(formatter,
|
17
|
-
method_name: value.value.to_sym).call
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def name
|
24
|
-
@node.value.value.to_sym
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
class Compiler
|
5
|
-
module Visitors
|
6
|
-
class BaseVisitor < SyntaxTree::Visitor
|
7
|
-
def initialize(compiler = nil)
|
8
|
-
@compiler = compiler
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def format(node)
|
14
|
-
Formatter.format("", node)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
class Compiler
|
5
|
-
module Visitors
|
6
|
-
class Component < BaseVisitor
|
7
|
-
visit_method def visit_def(node)
|
8
|
-
visitor = Visitors::ComponentMethod.new(@compiler)
|
9
|
-
visitor.visit_all(node.child_nodes)
|
10
|
-
|
11
|
-
if visitor.optimized_something?
|
12
|
-
@compiler.redefine(
|
13
|
-
format(node)
|
14
|
-
)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
visit_method def visit_class(node)
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
|
22
|
-
visit_method def visit_module(node)
|
23
|
-
nil
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
class Compiler
|
5
|
-
module Visitors
|
6
|
-
class ComponentMethod < BaseVisitor
|
7
|
-
def optimized_something?
|
8
|
-
!!@optimized_something
|
9
|
-
end
|
10
|
-
|
11
|
-
visit_method def visit_vcall(node)
|
12
|
-
@optimized_something = Optimizers::VCall.new(node,
|
13
|
-
compiler: @compiler).call
|
14
|
-
|
15
|
-
super
|
16
|
-
end
|
17
|
-
|
18
|
-
visit_method def visit_class(node)
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
|
22
|
-
visit_method def visit_module(node)
|
23
|
-
nil
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Phlex
|
4
|
-
module Rails
|
5
|
-
module TagHelpers
|
6
|
-
def form_with(*args, **kwargs, &block)
|
7
|
-
raw @_view_context.form_with(*args, **kwargs) { |form|
|
8
|
-
capture do
|
9
|
-
yield(
|
10
|
-
Phlex::Buffered.new(form, buffer: @_target)
|
11
|
-
)
|
12
|
-
end
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def csp_meta_tag
|
17
|
-
if (output = @_view_context.csp_meta_tag)
|
18
|
-
@_target << output
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def csrf_meta_tags
|
23
|
-
if (output = @_view_context.csrf_meta_tags)
|
24
|
-
@_target << output
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|