rbexy 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8c0ebb095f668e7b85fbd14fe770be07fc9f42565b7f71a02e4001a5a0c88c6
4
- data.tar.gz: 4670b8929fba14f2cdb197eca4c9d72f37ecdef6d1e84d33d43f18bdb09b0a07
3
+ metadata.gz: a6728982815c307bb37a495c3d11450e9582bf1cd17eef5306c9e940c0c36eea
4
+ data.tar.gz: 5fdfa1cc3c5fc70b573aa730f827b2f5d38b8031f1adc6344b31926ce520b4af
5
5
  SHA512:
6
- metadata.gz: 8e9920411ff9198828488d984cfd9e69c67e1ced6600a48d701c01153c4bc06419aaac58d2395ab61676798e9bb0a45137f40788d293fade0c0344c596e60c06
7
- data.tar.gz: 3da407f7258c3d2f2ef33a157747f6bf0f9ac945ebf801ec064430d80237f802ae7deac36de07a905b055dc9bd7f1958e80774a57f73d036a931a1c4cdac8b81
6
+ metadata.gz: 46385e65a3cd976497efd8d6db789eee4a2c73668e085dd6772d8c6a9a835783f6bb80ef923463af97cfec5d5625fffd641229a5a97a1c24e024b75d996969af
7
+ data.tar.gz: 025e25a41d9cc5e848342c668721cdef046ab13e5cff9737acc69a66eaca6cdd3ac06493bfcbb42b735fcbd6e7ae243e8a65588d648d3442924306944addb714
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbexy (1.0.2)
4
+ rbexy (1.1.0)
5
5
  actionview (>= 6.0, < 7.0)
6
6
  activesupport (>= 6.0, < 7.0)
7
7
 
@@ -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)
@@ -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(Rbexy::Rails::ComponentTemplateResolver.new(path))
21
+ prepend_view_path(ComponentTemplateResolver.new(path))
15
22
  end
16
23
  end
17
24
  end
@@ -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 = ::Rails.version.to_f >= 6.0 ?
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 Rbexy::ViewContextHelper
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 = Rbexy::ComponentProviders::RbexyProvider.new
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
@@ -8,6 +8,7 @@ module Rbexy
8
8
  include ActionView::Context
9
9
  include ActionView::Helpers::TagHelper
10
10
  include ViewContextHelper
11
+ include ComponentContext
11
12
 
12
13
  DefaultTagBuilder = ActionView::Helpers::TagHelper::TagBuilder
13
14
 
@@ -1,3 +1,3 @@
1
1
  module Rbexy
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -4,10 +4,6 @@ module Rbexy
4
4
  @rbexy_tag ||= Runtime.create_tag_builder(self)
5
5
  end
6
6
 
7
- def rbexy_context
8
- @rbexy_context ||= [{}]
9
- end
10
-
11
7
  def rbexy_prep_output(*value)
12
8
  return if value.length == 0
13
9
  value = value.first
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.2
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