arbre 1.7.0 → 2.0.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: 07b4de63d2e89a8ce69753438867bb05800ddc812b83bb630369dfbaec3df59d
4
- data.tar.gz: 8299e5287279509ec6578db4686114852e92ed0d386ceeeed22cbd7d1170fc02
3
+ metadata.gz: '0665748c1473cada55c30990ab9f793067a8a5e35b9b18196806ae6a1f9bb93e'
4
+ data.tar.gz: afa9e30b8d3152dbfef8d2fccbdf15dda7a314b90ed8e5ae9b44f45b92f977ee
5
5
  SHA512:
6
- metadata.gz: 9c01bb198d89bf938f853b2e0a4a674625cae8dfbd0fc56ed5fcc8bee974f92b451af63fd10b927c4ea61fcb88e6e78c81be8d2d3d8fe732347ca4b076b223c9
7
- data.tar.gz: 020135f9ed8db3a1d085e623250fb33e90d98591960d0ef68251f81e8ec9a93d82c42daff18b539a5884d1a431819a678a8cd046327fb0815b43504069d46d7f
6
+ metadata.gz: 1343be599798c86f1f37e161f8c3ac8a437bac46d7f278eff760cd9876755b7017774097d92594f9daa1929745322330f823bc19640c09666bb4cb775ba75875
7
+ data.tar.gz: f5751659a62d3451018bee66c14e8160267c4af97c2cc74846933383de1dd12de1bd93a1e9ccf8732f755ca43b1794b4a5a5be32c17991d27ab179a16d53f880
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## Master (unreleased)
3
+ ## 2.0.0 [☰](https://github.com/activeadmin/arbre/compare/v1.7.0...v2.0.0)
4
+
5
+ * Include empty attributes in HTML output. [#543][] by [@javierjulio][]
6
+ * Remove table tag defaults. [#542][] by [@javierjulio][]
7
+ * Remove component CSS class name default. [#545][] by [@javierjulio][]
4
8
 
5
9
  ## 1.7.0 [☰](https://github.com/activeadmin/arbre/compare/v1.6.0...v1.7.0)
6
10
 
@@ -127,6 +131,9 @@ Initial release and extraction from Active Admin
127
131
  [#456]: https://github.com/activeadmin/arbre/pull/456
128
132
  [#537]: https://github.com/activeadmin/arbre/pull/537
129
133
  [#539]: https://github.com/activeadmin/arbre/pull/539
134
+ [#542]: https://github.com/activeadmin/arbre/pull/542
135
+ [#543]: https://github.com/activeadmin/arbre/pull/543
136
+ [#545]: https://github.com/activeadmin/arbre/pull/545
130
137
 
131
138
  [@aramvisser]: https://github.com/aramvisser
132
139
  [@LTe]: https://github.com/LTe
data/docs/index.md CHANGED
@@ -49,7 +49,7 @@ This provides a simpler alternative to nesting partials.
49
49
  The recommended approach is to subclass Arbre::Component and implement a new builder method.
50
50
 
51
51
  The builder_method defines the method that will be called to build this component
52
- when using the DSL. The arguments passed into the builder_method will be passed
52
+ when using the DSL. The arguments passed into the builder_method will be passed
53
53
  into the #build method for you.
54
54
 
55
55
  For example:
@@ -66,7 +66,7 @@ class Panel < Arbre::Component
66
66
  end
67
67
  ```
68
68
 
69
- By default components are `div` tags with an HTML class corresponding to the component class name. This can be overridden by redefining the `tag_name` method.
69
+ By default, components are `div` tags. This can be overridden by redefining the `tag_name` method.
70
70
 
71
71
  Several examples of Arbre components are [included in Active Admin](https://activeadmin.info/12-arbre-components.html)
72
72
 
@@ -76,7 +76,7 @@ An [Arbre::Context](http://www.rubydoc.info/gems/arbre/Arbre/Context) is an obje
76
76
 
77
77
  ```ruby
78
78
  html = Arbre::Context.new do
79
- panel "Hello World", id: "my-panel" do
79
+ panel "Hello World", class: "panel", id: "my-panel" do
80
80
  span "Inside the panel"
81
81
  text_node "Plain text"
82
82
  end
@@ -1,23 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  module Arbre
3
3
  class Component < Arbre::HTML::Div
4
-
5
4
  # By default components render a div
6
5
  def tag_name
7
6
  'div'
8
7
  end
9
-
10
- def initialize(*)
11
- super
12
- add_class default_class_name
13
- end
14
-
15
- protected
16
-
17
- # By default, add a css class named after the ruby class
18
- def default_class_name
19
- self.class.name.demodulize.underscore
20
- end
21
-
22
8
  end
23
9
  end
data/lib/arbre/context.rb CHANGED
@@ -26,7 +26,6 @@ module Arbre
26
26
  # html.to_s #=> "Your number 1"
27
27
  #
28
28
  class Context < Element
29
-
30
29
  # Initialize a new Arbre::Context
31
30
  #
32
31
  # @param [Hash] assigns A hash of objecs that you would like to be
@@ -44,7 +43,7 @@ module Arbre
44
43
  @_current_arbre_element_buffer = [self]
45
44
 
46
45
  super(self)
47
- instance_eval(&block) if block_given?
46
+ instance_eval(&block) if block
48
47
  end
49
48
 
50
49
  def arbre_context
@@ -98,7 +97,6 @@ module Arbre
98
97
 
99
98
  private
100
99
 
101
-
102
100
  # Caches the rendered HTML so that we don't re-render just to
103
101
  # get the content length or to delegate a method to the HTML
104
102
  def cached_html
@@ -110,6 +108,5 @@ module Arbre
110
108
  html
111
109
  end
112
110
  end
113
-
114
111
  end
115
112
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Arbre
3
3
  class Element
4
-
5
4
  module BuilderMethods
6
5
 
7
6
  def self.included(klass)
@@ -25,11 +24,11 @@ module Arbre
25
24
  tag.parent = current_arbre_element
26
25
 
27
26
  with_current_arbre_element tag do
28
- if block_given? && block.arity > 0
27
+ if block && block.arity > 0
29
28
  tag.build(*args, &block)
30
29
  else
31
30
  tag.build(*args)
32
- append_return_block(yield) if block_given?
31
+ append_return_block(yield) if block
33
32
  end
34
33
  end
35
34
 
@@ -78,6 +77,5 @@ module Arbre
78
77
 
79
78
  end
80
79
  end
81
-
82
80
  end
83
81
  end
data/lib/arbre/element.rb CHANGED
@@ -185,6 +185,5 @@ module Arbre
185
185
  super
186
186
  end
187
187
  end
188
-
189
188
  end
190
189
  end
@@ -3,7 +3,6 @@ module Arbre
3
3
 
4
4
  # Stores a collection of Element objects
5
5
  class ElementCollection < Array
6
-
7
6
  def +(other)
8
7
  self.class.new(super)
9
8
  end
@@ -3,18 +3,12 @@ module Arbre
3
3
  module HTML
4
4
 
5
5
  class Attributes < Hash
6
-
7
6
  def to_s
8
- flatten_hash.map do |name, value|
9
- next if value_empty?(value)
7
+ flatten_hash.compact.map do |name, value|
10
8
  "#{html_escape(name)}=\"#{html_escape(value)}\""
11
9
  end.compact.join ' '
12
10
  end
13
11
 
14
- def any?
15
- super{ |k,v| !value_empty?(v) }
16
- end
17
-
18
12
  protected
19
13
 
20
14
  def flatten_hash(hash = self, old_path = [], accumulator = {})
@@ -29,10 +23,6 @@ module Arbre
29
23
  accumulator
30
24
  end
31
25
 
32
- def value_empty?(value)
33
- value.respond_to?(:empty?) ? value.empty? : !value
34
- end
35
-
36
26
  def html_escape(s)
37
27
  ERB::Util.html_escape(s)
38
28
  end
@@ -6,7 +6,6 @@ module Arbre
6
6
 
7
7
  # Holds a set of classes
8
8
  class ClassList < Set
9
-
10
9
  def self.build_from_string(class_names)
11
10
  new.add(class_names)
12
11
  end
@@ -22,7 +21,6 @@ module Arbre
22
21
  def to_s
23
22
  to_a.join(" ")
24
23
  end
25
-
26
24
  end
27
25
 
28
26
  end
@@ -3,7 +3,6 @@ module Arbre
3
3
  module HTML
4
4
 
5
5
  class Document < Tag
6
-
7
6
  def build(*args)
8
7
  super
9
8
  build_head
@@ -30,7 +29,7 @@ module Arbre
30
29
 
31
30
  def build_head
32
31
  @head = head do
33
- meta :"http-equiv" => "Content-type", content: "text/html; charset=utf-8"
32
+ meta "http-equiv": "Content-type", content: "text/html; charset=utf-8"
34
33
  end
35
34
  end
36
35
 
@@ -28,21 +28,5 @@ module Arbre
28
28
  builder_method :para
29
29
  end
30
30
 
31
- class Table < Tag
32
- def initialize(*)
33
- super
34
- set_table_tag_defaults
35
- end
36
-
37
- protected
38
-
39
- # Set some good defaults for tables
40
- def set_table_tag_defaults
41
- set_attribute :border, 0
42
- set_attribute :cellspacing, 0
43
- set_attribute :cellpadding, 0
44
- end
45
- end
46
-
47
31
  end
48
32
  end
@@ -165,7 +165,7 @@ module Arbre
165
165
  if record.class.respond_to?(:model_name)
166
166
  record.class.model_name.singular
167
167
  else
168
- record.class.name.underscore.gsub("/", "_")
168
+ record.class.name.underscore.tr("/", "_")
169
169
  end
170
170
  end
171
171
 
@@ -184,7 +184,6 @@ module Arbre
184
184
  def default_id_for_prefix
185
185
  nil
186
186
  end
187
-
188
187
  end
189
188
 
190
189
  end
@@ -5,7 +5,6 @@ module Arbre
5
5
  module HTML
6
6
 
7
7
  class TextNode < Element
8
-
9
8
  builder_method :text_node
10
9
 
11
10
  # Builds a text node from a string
@@ -38,7 +38,6 @@ module Arbre
38
38
  super
39
39
  end
40
40
  end
41
-
42
41
  end
43
42
 
44
43
  class FormForProxy < FormBuilderProxy
@@ -70,11 +69,9 @@ module Arbre
70
69
  def closing_tag
71
70
  @closing_tag || ""
72
71
  end
73
-
74
72
  end
75
73
 
76
74
  class FieldsForProxy < FormBuilderProxy
77
-
78
75
  def build(form_builder, *args, &block)
79
76
  form_builder.fields_for(*args) do |f|
80
77
  @form_builder = f
@@ -86,7 +83,6 @@ module Arbre
86
83
  def to_s
87
84
  children.to_s
88
85
  end
89
-
90
86
  end
91
87
 
92
88
  end
data/lib/arbre/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Arbre
3
- VERSION = "1.7.0"
3
+ VERSION = "2.0.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Bell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-08 00:00:00.000000000 Z
11
+ date: 2023-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport