phlex-rails 2.0.0.beta1 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/phlex/component/USAGE +8 -0
- data/lib/generators/phlex/component/templates/component.rb.erb +8 -0
- data/lib/generators/phlex/install/USAGE +10 -0
- data/lib/generators/phlex/install/install_generator.rb +1 -5
- data/lib/generators/phlex/install/templates/base_component.rb.erb +15 -0
- data/lib/generators/phlex/install/templates/base_view.rb.erb +9 -0
- data/lib/generators/phlex/install/templates/phlex.rb.erb +16 -0
- data/lib/generators/phlex/view/USAGE +8 -0
- data/lib/generators/phlex/view/templates/view.rb.erb +8 -0
- data/lib/phlex/rails/partial.rb +15 -0
- data/lib/phlex/rails/sgml.rb +21 -15
- data/lib/phlex/rails/testing.rb +1 -1
- data/lib/phlex/rails/version.rb +1 -1
- data/lib/phlex/rails.rb +2 -1
- metadata +15 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82a501ef5c7c4fafcc63ec4cab4c4e2463be6dbdb467af0bb87ef03cf0bd4b10
|
4
|
+
data.tar.gz: 781b9217536035e543e9ddc9db55dbfca518faf40974804eced2b49b8b9db97e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b21338b1d04ef04300133459bdbbf27d9cd07c023bbc7bdf0282c310ef214170be4d12a30fc9a1637fcc00db54329728ddd6852cd7d2d14fb047d651b37f3cee
|
7
|
+
data.tar.gz: 05f5a87850528bcf32ec8dafce55971a2dbdfaa5a17e0e7291d6a040e761da706ad83d54310562e8f0da59fb26b8cd5ed3d5642fa41bb95bf6304e187d7ad9a9
|
@@ -10,7 +10,7 @@ module Phlex::Generators
|
|
10
10
|
if tailwind_configuration_path
|
11
11
|
insert_into_file tailwind_configuration_path, after: "content: [" do
|
12
12
|
"\n './app/views/**/*.rb', // Phlex views" \
|
13
|
-
|
13
|
+
"\n './app/components/**/*.rb', // Phlex components" \
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -23,10 +23,6 @@ module Phlex::Generators
|
|
23
23
|
template "base_view.rb.erb", Rails.root.join("app/views/base.rb")
|
24
24
|
end
|
25
25
|
|
26
|
-
def create_hello_component
|
27
|
-
template "hello_component.rb.erb", Rails.root.join("app/components/hello.rb")
|
28
|
-
end
|
29
|
-
|
30
26
|
def create_initializer
|
31
27
|
template "phlex.rb.erb", Rails.root.join("config/initializers/phlex.rb")
|
32
28
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Components::Base < Phlex::HTML
|
4
|
+
include Components
|
5
|
+
|
6
|
+
# Include any helpers you want to be available across all components
|
7
|
+
include Phlex::Rails::Helpers::Routes
|
8
|
+
|
9
|
+
if Rails.env.development?
|
10
|
+
def before_template
|
11
|
+
comment { "Before #{self.class.name}" }
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Views::Base < Components::Base
|
4
|
+
# The `Views::Base` is an abstract class for all your views.
|
5
|
+
|
6
|
+
# By default, it inherits from `Components::Base`, but you
|
7
|
+
# can change that to `Phlex::HTML` if you want to keep views and
|
8
|
+
# components independent.
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Views
|
4
|
+
end
|
5
|
+
|
6
|
+
module Components
|
7
|
+
extend Phlex::Kit
|
8
|
+
end
|
9
|
+
|
10
|
+
Rails.autoloaders.main.push_dir(
|
11
|
+
"#{Rails.root}/app/views", namespace: Views
|
12
|
+
)
|
13
|
+
|
14
|
+
Rails.autoloaders.main.push_dir(
|
15
|
+
"#{Rails.root}/app/components", namespace: Components
|
16
|
+
)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Phlex::Rails::Partial
|
4
|
+
def initialize(path, *args, **kwargs, &block)
|
5
|
+
@path = path
|
6
|
+
@args = args
|
7
|
+
@kwargs = kwargs
|
8
|
+
@block = block
|
9
|
+
end
|
10
|
+
|
11
|
+
def render_in(view_context, &block)
|
12
|
+
block ||= @block
|
13
|
+
view_context.render(@path, *@args, **@kwargs, &block)
|
14
|
+
end
|
15
|
+
end
|
data/lib/phlex/rails/sgml.rb
CHANGED
@@ -10,11 +10,25 @@ module Phlex
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module Overrides
|
13
|
+
class HelpersCalledBeforeRenderError < StandardError; end
|
14
|
+
|
15
|
+
def partial(*, **, &block)
|
16
|
+
if block
|
17
|
+
Phlex::Rails::Partial.new(*, **) { capture(&block) }
|
18
|
+
else
|
19
|
+
Phlex::Rails::Partial.new(*, **)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
13
23
|
def helpers
|
14
|
-
|
15
|
-
|
24
|
+
unless @_context && (view_context = @_context.view_context)
|
25
|
+
raise HelpersCalledBeforeRenderError.new("Do not use rails helpers until after the view has been rendered.") unless view_context
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined?(ViewComponent::Base) && ViewComponent::Base === view_context
|
29
|
+
view_context.helpers
|
16
30
|
else
|
17
|
-
|
31
|
+
view_context
|
18
32
|
end
|
19
33
|
end
|
20
34
|
|
@@ -28,20 +42,12 @@ module Phlex
|
|
28
42
|
return super if renderable < Phlex::SGML
|
29
43
|
when Enumerable
|
30
44
|
return super unless ActiveRecord::Relation === renderable
|
31
|
-
when nil
|
32
|
-
partial = kwargs.delete(:partial)
|
33
|
-
|
34
|
-
if partial # this is a hack to get around https://github.com/rails/rails/issues/51015
|
35
|
-
return raw(
|
36
|
-
@_view_context.render(partial, **kwargs) do |*yielded_args|
|
37
|
-
capture(*yielded_args, &block)
|
38
|
-
end,
|
39
|
-
)
|
40
|
-
end
|
41
45
|
end
|
42
46
|
|
47
|
+
return super if args.length == 0 && kwargs.length == 0
|
48
|
+
|
43
49
|
output = if block
|
44
|
-
@
|
50
|
+
@_context.view_context.render(*args, **kwargs) do |*yielded_args|
|
45
51
|
if yielded_args.length == 1 && defined?(ViewComponent::Base) && ViewComponent::Base === yielded_args[0]
|
46
52
|
capture(Phlex::Rails::Buffered.new(yielded_args[0], view: self), &block)
|
47
53
|
else
|
@@ -49,7 +55,7 @@ module Phlex
|
|
49
55
|
end
|
50
56
|
end
|
51
57
|
else
|
52
|
-
@
|
58
|
+
@_context.view_context.render(*args, **kwargs)
|
53
59
|
end
|
54
60
|
|
55
61
|
raw(output)
|
data/lib/phlex/rails/testing.rb
CHANGED
data/lib/phlex/rails/version.rb
CHANGED
data/lib/phlex/rails.rb
CHANGED
@@ -12,11 +12,12 @@ module Phlex
|
|
12
12
|
autoload :BufferedRadioButtonBuilder, "phlex/rails/buffered_radio_button_builder"
|
13
13
|
autoload :CSV, "phlex/rails/csv"
|
14
14
|
autoload :FragmentFinder, "phlex/rails/fragment_finder"
|
15
|
+
autoload :HTML, "phlex/rails/html"
|
15
16
|
autoload :HelperFinder, "phlex/rails/helper_finder"
|
16
17
|
autoload :HelperMacros, "phlex/rails/helper_macros"
|
17
18
|
autoload :Helpers, "phlex/rails/helpers"
|
18
|
-
autoload :HTML, "phlex/rails/html"
|
19
19
|
autoload :Layout, "phlex/rails/layout"
|
20
|
+
autoload :Partial, "phlex/rails/partial"
|
20
21
|
autoload :SGML, "phlex/rails/sgml"
|
21
22
|
autoload :Streaming, "phlex/rails/streaming"
|
22
23
|
autoload :Unbuffered, "phlex/rails/unbuffered"
|
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: 2.0.0.
|
4
|
+
version: 2.0.0.rc1
|
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-
|
11
|
+
date: 2024-11-26 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: 2.0.0.
|
19
|
+
version: 2.0.0.rc1
|
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: 2.0.0.
|
26
|
+
version: 2.0.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '6.1'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '9'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '6.1'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '9'
|
47
47
|
description: A high-performance view framework optimised for fun.
|
48
48
|
email:
|
49
49
|
- joel@drapper.me
|
@@ -53,8 +53,16 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- LICENSE.txt
|
55
55
|
- README.md
|
56
|
+
- lib/generators/phlex/component/USAGE
|
56
57
|
- lib/generators/phlex/component/component_generator.rb
|
58
|
+
- lib/generators/phlex/component/templates/component.rb.erb
|
59
|
+
- lib/generators/phlex/install/USAGE
|
57
60
|
- lib/generators/phlex/install/install_generator.rb
|
61
|
+
- lib/generators/phlex/install/templates/base_component.rb.erb
|
62
|
+
- lib/generators/phlex/install/templates/base_view.rb.erb
|
63
|
+
- lib/generators/phlex/install/templates/phlex.rb.erb
|
64
|
+
- lib/generators/phlex/view/USAGE
|
65
|
+
- lib/generators/phlex/view/templates/view.rb.erb
|
58
66
|
- lib/generators/phlex/view/view_generator.rb
|
59
67
|
- lib/phlex-rails.rb
|
60
68
|
- lib/phlex/rails.rb
|
@@ -269,6 +277,7 @@ files:
|
|
269
277
|
- lib/phlex/rails/helpers/word_wrap.rb
|
270
278
|
- lib/phlex/rails/html.rb
|
271
279
|
- lib/phlex/rails/layout.rb
|
280
|
+
- lib/phlex/rails/partial.rb
|
272
281
|
- lib/phlex/rails/sgml.rb
|
273
282
|
- lib/phlex/rails/streaming.rb
|
274
283
|
- lib/phlex/rails/testing.rb
|