rbexy 1.0.2 → 1.1.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/Gemfile.lock +1 -1
- data/lib/rbexy.rb +1 -0
- data/lib/rbexy/component.rb +0 -11
- data/lib/rbexy/component_context.rb +18 -0
- data/lib/rbexy/rails/controller_helper.rb +8 -1
- data/lib/rbexy/rails/engine.rb +3 -7
- data/lib/rbexy/runtime.rb +1 -0
- data/lib/rbexy/version.rb +1 -1
- data/lib/rbexy/view_context_helper.rb +0 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6728982815c307bb37a495c3d11450e9582bf1cd17eef5306c9e940c0c36eea
|
4
|
+
data.tar.gz: 5fdfa1cc3c5fc70b573aa730f827b2f5d38b8031f1adc6344b31926ce520b4af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46385e65a3cd976497efd8d6db789eee4a2c73668e085dd6772d8c6a9a835783f6bb80ef923463af97cfec5d5625fffd641229a5a97a1c24e024b75d996969af
|
7
|
+
data.tar.gz: 025e25a41d9cc5e848342c668721cdef046ab13e5cff9737acc69a66eaca6cdd3ac06493bfcbb42b735fcbd6e7ae243e8a65588d648d3442924306944addb714
|
data/Gemfile.lock
CHANGED
data/lib/rbexy.rb
CHANGED
@@ -8,6 +8,7 @@ module Rbexy
|
|
8
8
|
autoload :HashMash, "rbexy/hash_mash"
|
9
9
|
autoload :ComponentTagBuilder, "rbexy/component_tag_builder"
|
10
10
|
autoload :ViewContextHelper, "rbexy/view_context_helper"
|
11
|
+
autoload :ComponentContext, "rbexy/component_context"
|
11
12
|
autoload :Configuration, "rbexy/configuration"
|
12
13
|
|
13
14
|
ContextNotFound = Class.new(StandardError)
|
data/lib/rbexy/component.rb
CHANGED
@@ -54,17 +54,6 @@ module Rbexy
|
|
54
54
|
content_block ? content_block.call : ""
|
55
55
|
end
|
56
56
|
|
57
|
-
def create_context(name, value)
|
58
|
-
rbexy_context.last[name] = value
|
59
|
-
end
|
60
|
-
|
61
|
-
def use_context(name)
|
62
|
-
index = rbexy_context.rindex { |c| c.has_key?(name) }
|
63
|
-
index ?
|
64
|
-
rbexy_context[index][name] :
|
65
|
-
raise(ContextNotFound, "no parent context `#{name}`")
|
66
|
-
end
|
67
|
-
|
68
57
|
def compiled_method_container
|
69
58
|
Rbexy::Component
|
70
59
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rbexy
|
2
|
+
module ComponentContext
|
3
|
+
def rbexy_context
|
4
|
+
@rbexy_context ||= [{}]
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_context(name, value)
|
8
|
+
rbexy_context.last[name] = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def use_context(name)
|
12
|
+
index = rbexy_context.rindex { |c| c.has_key?(name) }
|
13
|
+
index ?
|
14
|
+
rbexy_context[index][name] :
|
15
|
+
raise(ContextNotFound, "no parent context `#{name}`")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -4,14 +4,21 @@ module Rbexy
|
|
4
4
|
module Rails
|
5
5
|
module ControllerHelper
|
6
6
|
extend ActiveSupport::Concern
|
7
|
+
include ComponentContext
|
7
8
|
|
8
9
|
def rbexy_component_provider; end
|
9
10
|
|
11
|
+
included do
|
12
|
+
helper ViewContextHelper
|
13
|
+
helper_method :rbexy_component_provider
|
14
|
+
helper_method :rbexy_context, :create_context, :use_context
|
15
|
+
end
|
16
|
+
|
10
17
|
class_methods do
|
11
18
|
def inherited(klass)
|
12
19
|
super
|
13
20
|
Rbexy.configuration.template_paths.each do |path|
|
14
|
-
prepend_view_path(
|
21
|
+
prepend_view_path(ComponentTemplateResolver.new(path))
|
15
22
|
end
|
16
23
|
end
|
17
24
|
end
|
data/lib/rbexy/rails/engine.rb
CHANGED
@@ -4,25 +4,21 @@ module Rbexy
|
|
4
4
|
module Rails
|
5
5
|
class Engine < ::Rails::Engine
|
6
6
|
initializer "rbexy" do |app|
|
7
|
-
template_handler =
|
8
|
-
proc { |template, source| Rbexy.compile(source) } :
|
9
|
-
proc { |template| Rbexy.compile(template.source) }
|
7
|
+
template_handler = proc { |template, source| Rbexy.compile(source) }
|
10
8
|
|
11
9
|
ActionView::Template.register_template_handler(:rbx, template_handler)
|
12
10
|
|
13
11
|
ActiveSupport.on_load :action_controller_base do
|
14
|
-
helper Rbexy::ViewContextHelper
|
15
|
-
helper_method :rbexy_component_provider
|
16
12
|
include ControllerHelper
|
17
13
|
end
|
18
14
|
|
19
15
|
if defined?(ViewComponent)
|
20
|
-
ViewComponent::Base.include
|
16
|
+
ViewComponent::Base.include ViewContextHelper
|
21
17
|
end
|
22
18
|
|
23
19
|
Rbexy.configure do |config|
|
24
20
|
require "rbexy/component_providers/rbexy_provider"
|
25
|
-
config.component_provider =
|
21
|
+
config.component_provider = ComponentProviders::RbexyProvider.new
|
26
22
|
config.template_paths << ::Rails.root.join("app", "components")
|
27
23
|
config.enable_context = true
|
28
24
|
end
|
data/lib/rbexy/runtime.rb
CHANGED
data/lib/rbexy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbexy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Giancola
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- lib/rbexy.rb
|
206
206
|
- lib/rbexy/component.rb
|
207
207
|
- lib/rbexy/component/backtrace_cleaner.rb
|
208
|
+
- lib/rbexy/component_context.rb
|
208
209
|
- lib/rbexy/component_providers/namespaced_rbexy_provider.rb
|
209
210
|
- lib/rbexy/component_providers/rbexy_provider.rb
|
210
211
|
- lib/rbexy/component_providers/view_component_provider.rb
|