element_component 0.7.0 → 0.8.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.
@@ -33,7 +33,7 @@ module ElementComponent
33
33
  btn = Element.new("button", "aria-expanded": "false", "data-bs-toggle": "dropdown",
34
34
  class: "btn btn-#{variant} dropdown-toggle", type: "button", **btn_attributes)
35
35
  btn.add_content(label) if label
36
- instance_eval(&block) if block
36
+ block&.call(self)
37
37
  add_content(btn)
38
38
  end
39
39
  self
@@ -11,7 +11,7 @@ module ElementComponent
11
11
 
12
12
  add_attribute!(attribute)
13
13
  reset_contents!
14
- instance_eval(&block) if block
14
+ block&.call(self)
15
15
  end
16
16
 
17
17
  def add_content!(content)
@@ -82,9 +82,11 @@ module ElementComponent
82
82
 
83
83
  after_render(@html) if respond_to? "after_render"
84
84
 
85
- @html
85
+ defined?(ActiveSupport::SafeBuffer) ? @html.html_safe : @html
86
86
  end
87
87
 
88
+ def render_in(view_context, &block) = render
89
+
88
90
  private
89
91
 
90
92
  def build
@@ -105,7 +107,7 @@ module ElementComponent
105
107
  in Element
106
108
  content.render
107
109
  in Proc
108
- result = instance_eval(&content)
110
+ result = content.call(self)
109
111
  if result.equal?(self)
110
112
  ""
111
113
  elsif result.respond_to?(:render)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ElementComponent
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: element_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Paulo Correia