heartml 1.0.0.beta12 → 1.0.0.beta13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/heartml/rails/helpers.rb +9 -0
- data/lib/heartml/rails/railtie.rb +52 -0
- data/lib/heartml/rails/view_component_base.rb +38 -0
- data/lib/heartml/version.rb +1 -1
- data/lib/heartml.rb +1 -1
- metadata +5 -3
- data/lib/heartml/railtie.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34d9fbdea2b6e1a13db6ef196832ecc26e8b9b7309ab535e55322a1bc41f9365
|
4
|
+
data.tar.gz: 6a290783cd1351a473b78ba06640afad21591ab8d8c2c3d55b8c719e4d1b8d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a1840042e1dde5b672d3716475013f3249f2fc9a53affb8ed97eca4fe096e7a904f73a596b0b048db66231ccc6a4aeeef9ce3e5c45d581c36a0308275328f1
|
7
|
+
data.tar.gz: a59ed8c042924e27ffe47f3fad6a13e7d506450b1d5e426f4c29fbde5edd5a005c59b67ced6c2c7b20f2e5c2e9b594814bde901b961e80fa87433a36174e1495
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -0,0 +1,52 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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
|
+
module ClassMethods
|
20
|
+
def compile(*)
|
21
|
+
# no-op
|
22
|
+
end
|
23
|
+
|
24
|
+
def compiled? = true
|
25
|
+
|
26
|
+
def inherited(klass)
|
27
|
+
super(klass)
|
28
|
+
klass.source_location = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].path
|
29
|
+
klass.virtual_path = klass.source_location.gsub(
|
30
|
+
%r{(.*#{Regexp.quote(ViewComponent::Base.config.view_component_path)})|(\.rb)}, ""
|
31
|
+
)
|
32
|
+
Heartml::ServerEffects.included_extras(klass)
|
33
|
+
klass.directives.merge! directives
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/heartml/version.rb
CHANGED
data/lib/heartml.rb
CHANGED
@@ -398,4 +398,4 @@ end
|
|
398
398
|
|
399
399
|
require_relative "heartml/template_renderer"
|
400
400
|
require_relative "heartml/bridgetown_renderer" if defined?(Bridgetown)
|
401
|
-
require_relative "heartml/railtie" if defined?(Rails::Railtie)
|
401
|
+
require_relative "heartml/rails/railtie" if defined?(Rails::Railtie)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.beta13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -59,7 +59,9 @@ files:
|
|
59
59
|
- lib/heartml/bridgetown_renderer.rb
|
60
60
|
- lib/heartml/fragment.rb
|
61
61
|
- lib/heartml/query_selection.rb
|
62
|
-
- lib/heartml/
|
62
|
+
- lib/heartml/rails/helpers.rb
|
63
|
+
- lib/heartml/rails/railtie.rb
|
64
|
+
- lib/heartml/rails/view_component_base.rb
|
63
65
|
- lib/heartml/server_effects.rb
|
64
66
|
- lib/heartml/template_renderer.rb
|
65
67
|
- lib/heartml/version.rb
|
data/lib/heartml/railtie.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Heartml
|
4
|
-
class Railtie < ::Rails::Railtie
|
5
|
-
module ReloadDocsInDevelopment
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
before_action :reload_docs
|
10
|
-
end
|
11
|
-
|
12
|
-
def reload_docs
|
13
|
-
Heartml.registered_elements.each { _1.instance_variable_set(:@doc, nil) }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
initializer "heartml.reload_docs_in_development" do |_app|
|
18
|
-
unless Rails.env.production?
|
19
|
-
ActiveSupport.on_load(:action_controller_base) do
|
20
|
-
include ReloadDocsInDevelopment
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
config.to_prepare do
|
26
|
-
next if Rails.env.production?
|
27
|
-
|
28
|
-
components_folder = Rails.root.join("app", "components")
|
29
|
-
unless File.directory?(components_folder)
|
30
|
-
Rails.logger.error "Heartml: missing `app/components' folder, cannot load elements"
|
31
|
-
next
|
32
|
-
end
|
33
|
-
|
34
|
-
Rails.autoloaders.main.eager_load_dir components_folder
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|