element_component 0.8.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cbfcfb824fb827c1bd03d08c5b2d0eec50fefa7b06c392b3e3393ce07c445be
4
- data.tar.gz: ef7c00a35e38318c158fd43397552d37559d62c6996ca2f9a1a0dd05c2e32fc7
3
+ metadata.gz: 8919d998e1eed755c1b0d52a1a755b913c00befed273951da5fab55bc2a6def4
4
+ data.tar.gz: cdb3938426b25800c14566531c14758d7202ede0e6faa76b765f7ace39530219
5
5
  SHA512:
6
- metadata.gz: f8297bcae5e86b8201fec505845b928dcf77bcfe4fc28d2d034c29b702446cf0e5566cc82468826b70173aa2392ea4c8b400b9eeeeeabad173923688ff4b5364
7
- data.tar.gz: 934369f2c1d3a14b74437f6b71427ae1c92fa4ba3e27054f5755fe793e1442fa3c565783d96ce1cfa209a8cbbd35b5da338688910228240c291736ed9d24d46c
6
+ metadata.gz: 37fa2859a76cc025dae9c07765e0ab492a8a79970da462f01225d20fa7c146fe850d1915882e5891fd42cbf2046de8828e25c052d3d518a8f699996b0fe2002a
7
+ data.tar.gz: c53fb1bf1fec326bd4ae2daafc2b704923e9a7a6fae40006d28fea7d656b4d3c0419e1250121a5989630e2e8f53a46c45e1e6d63a04d299582e0515ddde3f06e
data/README.md CHANGED
@@ -80,6 +80,11 @@ div.add_content { |e| e.new_element("em") { |em| em.add_content("deferred") } }
80
80
 
81
81
  puts div.render
82
82
  # => <div>plain text<span>nested</span><em>deferred</em></div>
83
+
84
+ # Array of content
85
+ div.add_content(["Hello ", ElementComponent::Element.new("strong") { |s| s.add_content("World") }, "!"])
86
+ puts div.render
87
+ # => <div>Hello <strong>World</strong>!</div>
83
88
  ```
84
89
 
85
90
  ### Attribute Management
@@ -14,15 +14,17 @@ module ElementComponent
14
14
  block&.call(self)
15
15
  end
16
16
 
17
- def add_content!(content)
17
+ def add_content!(content = nil, &)
18
18
  reset_contents!
19
19
 
20
- add_content(content)
20
+ add_content(content, &)
21
21
  end
22
22
 
23
23
  def add_content(content = nil, &block)
24
24
  if block_given?
25
25
  @contents.push(block)
26
+ elsif content.is_a?(Array)
27
+ @contents.push(*content)
26
28
  else
27
29
  @contents.push(content)
28
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ElementComponent
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Paulo Correia