heartml 1.0.0.beta19 → 1.0.0.beta21
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/.rubocop.yml +5 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +77 -58
- data/README.md +3 -7
- data/heartml.gemspec +4 -4
- data/lib/heartml/fragment.rb +2 -2
- data/lib/heartml/template_renderer.rb +2 -2
- data/lib/heartml/version.rb +1 -1
- data/lib/heartml.rb +5 -6
- metadata +8 -15
- data/lib/heartml/rails/helpers.rb +0 -9
- data/lib/heartml/rails/railtie.rb +0 -52
- data/lib/heartml/rails/view_component_base.rb +0 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1735f81c38ee8e708fc5f4427235e9cedf15b85abe5ab8e20f9779e12490cf65
|
|
4
|
+
data.tar.gz: 8dc571fdffd6fb7d9867dccc5c582c3df9b4008ba1f166b804ec26161ae0ede9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ebe339cb299389e2d07f3bfaa3b527b58d638db31ca98dd342ffd005177a29c1699cb7164995a0dd76c1fea6a5127cdcb517590870e9d87253ab53321cbdf86d
|
|
7
|
+
data.tar.gz: 4c6f02662698f7f0d679a4a2f861e3f0f9ba256d2643de584f4754a21592a8859e1fe2405da535bedb1bfbc41c8bc38feea5896631aee3cb571f788eb07389fc
|
data/.rubocop.yml
CHANGED
|
@@ -3,7 +3,7 @@ require:
|
|
|
3
3
|
- rubocop-rake
|
|
4
4
|
|
|
5
5
|
AllCops:
|
|
6
|
-
TargetRubyVersion: 3.
|
|
6
|
+
TargetRubyVersion: 3.2
|
|
7
7
|
NewCops: enable
|
|
8
8
|
|
|
9
9
|
Metrics/MethodLength:
|
|
@@ -12,6 +12,10 @@ Metrics/MethodLength:
|
|
|
12
12
|
Metrics/ModuleLength:
|
|
13
13
|
Enabled: false
|
|
14
14
|
|
|
15
|
+
Naming/PredicateMethod:
|
|
16
|
+
Exclude:
|
|
17
|
+
- test/**/*.rb
|
|
18
|
+
|
|
15
19
|
Style/Documentation:
|
|
16
20
|
Enabled: false
|
|
17
21
|
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [1.0.0.beta21] - 2025-12-12
|
|
6
|
+
|
|
7
|
+
- Tighten Bridgetown feature detection (only check for `Bridgetown::Component`)
|
|
8
|
+
- Updated minimum Ruby version to 3.2
|
|
9
|
+
|
|
10
|
+
## [1.0.0.beta20] - 2025-08-23
|
|
11
|
+
|
|
12
|
+
- Remove support for Rails / ViewComponent
|
|
13
|
+
(due to my personal no-support-for-37signals policy because DHH is a fascist)
|
|
14
|
+
|
|
5
15
|
## [1.0.0.beta19] — 2025-03-16
|
|
6
16
|
|
|
7
17
|
- Update to minimum support for ViewComponent 3.21.0 API
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,109 +1,128 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
heartml (1.0.0.
|
|
4
|
+
heartml (1.0.0.beta21)
|
|
5
5
|
concurrent-ruby (~> 1.2)
|
|
6
6
|
nokolexbor (>= 0.4.2)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activesupport (7.
|
|
11
|
+
activesupport (7.2.3)
|
|
12
12
|
base64
|
|
13
|
+
benchmark (>= 0.3)
|
|
13
14
|
bigdecimal
|
|
14
|
-
concurrent-ruby (~> 1.0, >= 1.
|
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
15
16
|
connection_pool (>= 2.2.5)
|
|
16
17
|
drb
|
|
17
18
|
i18n (>= 1.6, < 2)
|
|
19
|
+
logger (>= 1.4.2)
|
|
18
20
|
minitest (>= 5.1)
|
|
19
|
-
|
|
20
|
-
tzinfo (~> 2.0)
|
|
21
|
-
ast (2.4.
|
|
21
|
+
securerandom (>= 0.3)
|
|
22
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
23
|
+
ast (2.4.3)
|
|
22
24
|
backport (1.2.0)
|
|
23
|
-
base64 (0.
|
|
24
|
-
benchmark (0.
|
|
25
|
-
bigdecimal (3.1
|
|
26
|
-
concurrent-ruby (1.
|
|
27
|
-
connection_pool (
|
|
28
|
-
diff-lcs (1.
|
|
29
|
-
drb (2.2.
|
|
30
|
-
ruby2_keywords
|
|
31
|
-
e2mmap (0.1.0)
|
|
25
|
+
base64 (0.3.0)
|
|
26
|
+
benchmark (0.5.0)
|
|
27
|
+
bigdecimal (3.3.1)
|
|
28
|
+
concurrent-ruby (1.3.5)
|
|
29
|
+
connection_pool (3.0.2)
|
|
30
|
+
diff-lcs (1.6.2)
|
|
31
|
+
drb (2.2.3)
|
|
32
32
|
hash_with_dot_access (1.2.0)
|
|
33
33
|
activesupport (>= 5.0.0, < 8.0)
|
|
34
|
-
i18n (1.14.
|
|
34
|
+
i18n (1.14.7)
|
|
35
35
|
concurrent-ruby (~> 1.0)
|
|
36
|
-
jaro_winkler (1.
|
|
37
|
-
json (2.
|
|
38
|
-
kramdown (2.
|
|
39
|
-
rexml
|
|
36
|
+
jaro_winkler (1.6.1)
|
|
37
|
+
json (2.18.0)
|
|
38
|
+
kramdown (2.5.1)
|
|
39
|
+
rexml (>= 3.3.9)
|
|
40
40
|
kramdown-parser-gfm (1.1.0)
|
|
41
41
|
kramdown (~> 2.0)
|
|
42
|
-
language_server-protocol (3.17.0.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
language_server-protocol (3.17.0.5)
|
|
43
|
+
lint_roller (1.1.0)
|
|
44
|
+
logger (1.7.0)
|
|
45
|
+
mini_portile2 (2.8.9)
|
|
46
|
+
minitest (5.27.0)
|
|
47
|
+
nokogiri (1.18.10)
|
|
47
48
|
mini_portile2 (~> 2.8.2)
|
|
48
49
|
racc (~> 1.4)
|
|
49
|
-
nokogiri (1.
|
|
50
|
+
nokogiri (1.18.10-arm64-darwin)
|
|
50
51
|
racc (~> 1.4)
|
|
51
|
-
nokogiri (1.
|
|
52
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
|
52
53
|
racc (~> 1.4)
|
|
53
|
-
nokolexbor (0.6.
|
|
54
|
-
nokolexbor (0.6.
|
|
55
|
-
nokolexbor (0.6.
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
nokolexbor (0.6.2)
|
|
55
|
+
nokolexbor (0.6.2-arm64-darwin)
|
|
56
|
+
nokolexbor (0.6.2-x86_64-linux)
|
|
57
|
+
observer (0.1.2)
|
|
58
|
+
ostruct (0.6.3)
|
|
59
|
+
parallel (1.27.0)
|
|
60
|
+
parser (3.3.10.0)
|
|
58
61
|
ast (~> 2.4.1)
|
|
59
62
|
racc
|
|
60
|
-
|
|
63
|
+
prism (1.6.0)
|
|
64
|
+
racc (1.8.1)
|
|
61
65
|
rainbow (3.1.1)
|
|
62
|
-
rake (13.1
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
rake (13.3.1)
|
|
67
|
+
rbs (3.9.5)
|
|
68
|
+
logger
|
|
69
|
+
regexp_parser (2.11.3)
|
|
70
|
+
reverse_markdown (3.0.1)
|
|
65
71
|
nokogiri
|
|
66
|
-
rexml (3.
|
|
67
|
-
rubocop (1.
|
|
72
|
+
rexml (3.4.4)
|
|
73
|
+
rubocop (1.81.7)
|
|
68
74
|
json (~> 2.3)
|
|
69
|
-
language_server-protocol (
|
|
75
|
+
language_server-protocol (~> 3.17.0.2)
|
|
76
|
+
lint_roller (~> 1.1.0)
|
|
70
77
|
parallel (~> 1.10)
|
|
71
78
|
parser (>= 3.3.0.2)
|
|
72
79
|
rainbow (>= 2.2.2, < 4.0)
|
|
73
|
-
regexp_parser (>=
|
|
74
|
-
|
|
75
|
-
rubocop-ast (>= 1.30.0, < 2.0)
|
|
80
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
81
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
76
82
|
ruby-progressbar (~> 1.7)
|
|
77
|
-
unicode-display_width (>= 2.4.0, <
|
|
78
|
-
rubocop-ast (1.
|
|
79
|
-
parser (>= 3.
|
|
83
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
84
|
+
rubocop-ast (1.48.0)
|
|
85
|
+
parser (>= 3.3.7.2)
|
|
86
|
+
prism (~> 1.4)
|
|
80
87
|
rubocop-minitest (0.22.2)
|
|
81
88
|
rubocop (>= 0.90, < 2.0)
|
|
82
89
|
rubocop-rake (0.6.0)
|
|
83
90
|
rubocop (~> 1.0)
|
|
84
91
|
ruby-progressbar (1.13.0)
|
|
85
|
-
|
|
86
|
-
solargraph (0.
|
|
92
|
+
securerandom (0.4.1)
|
|
93
|
+
solargraph (0.57.0)
|
|
87
94
|
backport (~> 1.2)
|
|
88
|
-
benchmark
|
|
89
|
-
bundler (
|
|
95
|
+
benchmark (~> 0.4)
|
|
96
|
+
bundler (~> 2.0)
|
|
90
97
|
diff-lcs (~> 1.4)
|
|
91
|
-
|
|
92
|
-
jaro_winkler (~> 1.5)
|
|
98
|
+
jaro_winkler (~> 1.6, >= 1.6.1)
|
|
93
99
|
kramdown (~> 2.3)
|
|
94
100
|
kramdown-parser-gfm (~> 1.1)
|
|
101
|
+
logger (~> 1.6)
|
|
102
|
+
observer (~> 0.1)
|
|
103
|
+
ostruct (~> 0.6)
|
|
95
104
|
parser (~> 3.0)
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
prism (~> 1.4)
|
|
106
|
+
rbs (>= 3.6.1, <= 4.0.0.dev.4)
|
|
107
|
+
reverse_markdown (~> 3.0)
|
|
108
|
+
rubocop (~> 1.76)
|
|
98
109
|
thor (~> 1.0)
|
|
99
110
|
tilt (~> 2.0)
|
|
100
111
|
yard (~> 0.9, >= 0.9.24)
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
yard-activesupport-concern (~> 0.0)
|
|
113
|
+
yard-solargraph (~> 0.1)
|
|
114
|
+
thor (1.4.0)
|
|
115
|
+
tilt (2.6.1)
|
|
103
116
|
tzinfo (2.0.6)
|
|
104
117
|
concurrent-ruby (~> 1.0)
|
|
105
|
-
unicode-display_width (2.
|
|
106
|
-
|
|
118
|
+
unicode-display_width (3.2.0)
|
|
119
|
+
unicode-emoji (~> 4.1)
|
|
120
|
+
unicode-emoji (4.1.0)
|
|
121
|
+
yard (0.9.38)
|
|
122
|
+
yard-activesupport-concern (0.0.1)
|
|
123
|
+
yard (>= 0.8)
|
|
124
|
+
yard-solargraph (0.1.0)
|
|
125
|
+
yard (~> 0.9)
|
|
107
126
|
|
|
108
127
|
PLATFORMS
|
|
109
128
|
arm64-darwin-21
|
|
@@ -118,7 +137,7 @@ DEPENDENCIES
|
|
|
118
137
|
rubocop (~> 1.21)
|
|
119
138
|
rubocop-minitest (~> 0.22.1)
|
|
120
139
|
rubocop-rake (~> 0.6.0)
|
|
121
|
-
solargraph (~> 0.47
|
|
140
|
+
solargraph (~> 0.47)
|
|
122
141
|
|
|
123
142
|
BUNDLED WITH
|
|
124
143
|
2.3.14
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Heartml: Ruby Web Components (WIP)
|
|
2
2
|
|
|
3
|
-
Server-rendered custom elements in Ruby using a SFC (Single-File Component) format loosely based on [HTML Modules](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-explainer.md). Logic on the server-side is analogous to client-side logic provided by the [Heartml JavaScript library](https://
|
|
3
|
+
Server-rendered custom elements in Ruby using a SFC (Single-File Component) format loosely based on [HTML Modules](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-explainer.md). Logic on the server-side is analogous to client-side logic provided by the [Heartml JavaScript library](https://codeberg.org/heartml/heartml).
|
|
4
4
|
|
|
5
|
-
Great for pairing with [esbuild-plugin-html-modules](https://
|
|
5
|
+
Great for pairing with [esbuild-plugin-html-modules](https://codeberg.org/jaredwhite/esbuild-plugin-html-modules) for a full-stack component rendering pipeline.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -26,12 +26,8 @@ To install this gem onto your local machine, run `bin/rake install`. To release
|
|
|
26
26
|
|
|
27
27
|
## Contributing
|
|
28
28
|
|
|
29
|
-
Bug reports and pull requests are welcome on
|
|
29
|
+
Bug reports and pull requests are welcome on Codeberg at https://codeberg.org/heartml/heartml-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://codeberg.org/heartml/heartml-ruby/src/branch/main/CODE_OF_CONDUCT.md).
|
|
30
30
|
|
|
31
31
|
## License
|
|
32
32
|
|
|
33
33
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
34
|
-
|
|
35
|
-
## Code of Conduct
|
|
36
|
-
|
|
37
|
-
Everyone interacting in the Heartml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/heartml/heartml-ruby/blob/main/CODE_OF_CONDUCT.md).
|
data/heartml.gemspec
CHANGED
|
@@ -9,13 +9,13 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.email = ["jared@whitefusion.studio"]
|
|
10
10
|
|
|
11
11
|
spec.summary = "Server-rendered web components"
|
|
12
|
-
spec.homepage = "https://
|
|
12
|
+
spec.homepage = "https://codeberg.org/heartml/heartml-ruby#readme"
|
|
13
13
|
spec.license = "MIT"
|
|
14
|
-
spec.required_ruby_version = ">= 3.
|
|
14
|
+
spec.required_ruby_version = ">= 3.2"
|
|
15
15
|
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
-
spec.metadata["source_code_uri"] = "https://
|
|
18
|
-
spec.metadata["changelog_uri"] = "https://
|
|
17
|
+
spec.metadata["source_code_uri"] = "https://codeberg.org/heartml/heartml-ruby"
|
|
18
|
+
spec.metadata["changelog_uri"] = "https://codeberg.org/heartml/heartml-ruby/src/branch/main/CHANGELOG.md"
|
|
19
19
|
spec.metadata["rubygems_mfa_required"] = "true"
|
|
20
20
|
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
data/lib/heartml/fragment.rb
CHANGED
|
@@ -13,9 +13,9 @@ module Heartml
|
|
|
13
13
|
# NOTE: for some reason, the traverse method yields node children first, then the
|
|
14
14
|
# parent node. That doesn't work for our case. We want to go strictly in source order.
|
|
15
15
|
# So this is our own implementation of that.
|
|
16
|
-
def traverse(node, &block)
|
|
16
|
+
def traverse(node, &block)
|
|
17
17
|
yield(node)
|
|
18
|
-
node.children.each { |child| traverse(child, &block) }
|
|
18
|
+
node.children.each { |child| traverse(child, &block) }
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def process(fragment = @fragment) # rubocop:disable Metrics
|
data/lib/heartml/version.rb
CHANGED
data/lib/heartml.rb
CHANGED
|
@@ -34,8 +34,8 @@ module Heartml
|
|
|
34
34
|
@registered_elements.each do |component|
|
|
35
35
|
begin
|
|
36
36
|
next if Kernel.const_get(component.to_s) == component # thin out unloaded consts
|
|
37
|
-
rescue NameError
|
|
38
|
-
|
|
37
|
+
rescue NameError # rubocop:disable Lint/SuppressedException
|
|
38
|
+
end
|
|
39
39
|
@registered_elements.delete component
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -65,7 +65,7 @@ module Heartml
|
|
|
65
65
|
|
|
66
66
|
ServerEffects.included_extras(klass)
|
|
67
67
|
|
|
68
|
-
return unless defined?(Bridgetown) && klass < Bridgetown::Component
|
|
68
|
+
return unless defined?(Bridgetown::Component) && klass < Bridgetown::Component
|
|
69
69
|
|
|
70
70
|
BridgetownRenderer.component_overrides(klass)
|
|
71
71
|
end
|
|
@@ -190,7 +190,7 @@ module Heartml
|
|
|
190
190
|
|
|
191
191
|
tmpl_el = doc.css("> template").find do |node|
|
|
192
192
|
node.attributes.empty? ||
|
|
193
|
-
(node.attributes.
|
|
193
|
+
(node.attributes.one? && node.attributes.any? { |k| k[0] == "data-ssr-only" })
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
if tmpl_el
|
|
@@ -369,5 +369,4 @@ module Heartml
|
|
|
369
369
|
end
|
|
370
370
|
|
|
371
371
|
require_relative "heartml/template_renderer"
|
|
372
|
-
require_relative "heartml/bridgetown_renderer" if defined?(Bridgetown)
|
|
373
|
-
require_relative "heartml/rails/railtie" if defined?(Rails::Railtie)
|
|
372
|
+
require_relative "heartml/bridgetown_renderer" if defined?(Bridgetown::Component)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: heartml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0.
|
|
4
|
+
version: 1.0.0.beta21
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jared White
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
10
|
+
date: 2025-12-12 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: concurrent-ruby
|
|
@@ -38,7 +37,6 @@ dependencies:
|
|
|
38
37
|
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: 0.4.2
|
|
41
|
-
description:
|
|
42
40
|
email:
|
|
43
41
|
- jared@whitefusion.studio
|
|
44
42
|
executables: []
|
|
@@ -59,21 +57,17 @@ files:
|
|
|
59
57
|
- lib/heartml/bridgetown_renderer.rb
|
|
60
58
|
- lib/heartml/fragment.rb
|
|
61
59
|
- lib/heartml/query_selection.rb
|
|
62
|
-
- lib/heartml/rails/helpers.rb
|
|
63
|
-
- lib/heartml/rails/railtie.rb
|
|
64
|
-
- lib/heartml/rails/view_component_base.rb
|
|
65
60
|
- lib/heartml/server_effects.rb
|
|
66
61
|
- lib/heartml/template_renderer.rb
|
|
67
62
|
- lib/heartml/version.rb
|
|
68
|
-
homepage: https://
|
|
63
|
+
homepage: https://codeberg.org/heartml/heartml-ruby#readme
|
|
69
64
|
licenses:
|
|
70
65
|
- MIT
|
|
71
66
|
metadata:
|
|
72
|
-
homepage_uri: https://
|
|
73
|
-
source_code_uri: https://
|
|
74
|
-
changelog_uri: https://
|
|
67
|
+
homepage_uri: https://codeberg.org/heartml/heartml-ruby#readme
|
|
68
|
+
source_code_uri: https://codeberg.org/heartml/heartml-ruby
|
|
69
|
+
changelog_uri: https://codeberg.org/heartml/heartml-ruby/src/branch/main/CHANGELOG.md
|
|
75
70
|
rubygems_mfa_required: 'true'
|
|
76
|
-
post_install_message:
|
|
77
71
|
rdoc_options: []
|
|
78
72
|
require_paths:
|
|
79
73
|
- lib
|
|
@@ -81,15 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
81
75
|
requirements:
|
|
82
76
|
- - ">="
|
|
83
77
|
- !ruby/object:Gem::Version
|
|
84
|
-
version: '3.
|
|
78
|
+
version: '3.2'
|
|
85
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
80
|
requirements:
|
|
87
81
|
- - ">="
|
|
88
82
|
- !ruby/object:Gem::Version
|
|
89
83
|
version: '0'
|
|
90
84
|
requirements: []
|
|
91
|
-
rubygems_version: 3.
|
|
92
|
-
signing_key:
|
|
85
|
+
rubygems_version: 3.6.2
|
|
93
86
|
specification_version: 4
|
|
94
87
|
summary: Server-rendered web components
|
|
95
88
|
test_files: []
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Heartml
|
|
4
|
-
module Rails
|
|
5
|
-
class Railtie < ::Rails::Railtie
|
|
6
|
-
module ReloadDocsInDevelopment
|
|
7
|
-
extend ActiveSupport::Concern
|
|
8
|
-
|
|
9
|
-
included do
|
|
10
|
-
before_action :reload_docs
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def reload_docs
|
|
14
|
-
Heartml.registered_elements.each { _1.instance_variable_set(:@doc, nil) }
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
require "heartml/rails/helpers"
|
|
19
|
-
ActionView::Helpers.include Heartml::Rails::Helpers
|
|
20
|
-
|
|
21
|
-
initializer "heartml.monkypatch_view_component" do |_app|
|
|
22
|
-
require "view_component/base"
|
|
23
|
-
require "heartml/rails/view_component_base"
|
|
24
|
-
ViewComponent::Base.class_eval do
|
|
25
|
-
def self.heartml = include Heartml::Rails::ViewComponentBase
|
|
26
|
-
end
|
|
27
|
-
rescue LoadError
|
|
28
|
-
# no ViewComponent to patch
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
initializer "heartml.reload_docs_in_development" do |_app|
|
|
32
|
-
unless ::Rails.env.production?
|
|
33
|
-
ActiveSupport.on_load(:action_controller_base) do
|
|
34
|
-
include ReloadDocsInDevelopment
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
config.to_prepare do
|
|
40
|
-
next if ::Rails.env.production?
|
|
41
|
-
|
|
42
|
-
components_folder = ::Rails.root.join("app", "components")
|
|
43
|
-
unless File.directory?(components_folder)
|
|
44
|
-
::Rails.logger.error "Heartml: missing `app/components' folder, cannot load elements"
|
|
45
|
-
next
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
::Rails.autoloaders.main.eager_load_dir components_folder
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Heartml
|
|
4
|
-
module Rails
|
|
5
|
-
module ViewComponentBase
|
|
6
|
-
def self.included(klass)
|
|
7
|
-
klass.remove_method :render_template_for
|
|
8
|
-
klass.extend ClassMethods
|
|
9
|
-
klass.include Heartml
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def render_in(view_context, rendering_mode: :string, &block)
|
|
13
|
-
self.rendering_mode = rendering_mode
|
|
14
|
-
super(view_context, &block)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def render_template_for(*) = call
|
|
18
|
-
|
|
19
|
-
# No escaping required for the rendered HTML
|
|
20
|
-
def maybe_escape_html(input) = input
|
|
21
|
-
|
|
22
|
-
module ClassMethods
|
|
23
|
-
def compile(*)
|
|
24
|
-
# no-op
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def compiled? = true
|
|
28
|
-
|
|
29
|
-
def inherited(klass)
|
|
30
|
-
super(klass)
|
|
31
|
-
klass.identifier = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].path
|
|
32
|
-
klass.virtual_path = klass.identifier.gsub(
|
|
33
|
-
%r{(.*#{Regexp.quote(ViewComponent::Base.config.view_component_path)})|(\.rb)}, ""
|
|
34
|
-
)
|
|
35
|
-
Heartml::ServerEffects.included_extras(klass)
|
|
36
|
-
klass.directives.merge! directives
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def source_location = identifier
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|