Skip to content

Commit 43bc2a8

Browse files
committed
Removed any references to to_html within our Arbre components (use to_s)
1 parent 67e27b9 commit 43bc2a8

File tree

13 files changed

+43
-51
lines changed

13 files changed

+43
-51
lines changed

lib/active_admin/arbre/context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def cached_html
3535
if defined?(@cached_html)
3636
@cached_html
3737
else
38-
html = to_html
38+
html = to_s
3939
@cached_html = html if html.length > 0
4040
html
4141
end

lib/active_admin/arbre/html/attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module HTML
33

44
class Attributes < Hash
55

6-
def to_html
6+
def to_s
77
self.collect do |name, value|
88
"#{html_escape(name)}=\"#{html_escape(value)}\""
99
end.join(" ")

lib/active_admin/arbre/html/class_list.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ def add(class_names)
1515
alias :<< :add
1616

1717
def to_s
18-
to_html
19-
end
20-
21-
def to_html
2218
to_a.join(" ")
2319
end
2420

lib/active_admin/arbre/html/collection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def &(other)
1616
self.class.new(super)
1717
end
1818

19-
def to_html
19+
def to_s
2020
self.collect do |element|
21-
element.to_html
21+
element.to_s
2222
end.join.html_safe
2323
end
2424
end

lib/active_admin/arbre/html/document.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def doctype
2121
'<!DOCTYPE html>'.html_safe
2222
end
2323

24-
def to_html
24+
def to_s
2525
doctype + super
2626
end
2727

lib/active_admin/arbre/html/element.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,30 +108,26 @@ def get_elements_by_class_name(class_name)
108108
alias_method :find_by_class, :get_elements_by_class_name
109109

110110
def content
111-
children.to_html
111+
children.to_s
112112
end
113113

114114
def html_safe
115-
to_html
115+
to_s
116116
end
117117

118118
def indent_level
119119
parent? ? parent.indent_level + 1 : 0
120120
end
121121

122122
def each(&block)
123-
[to_html].each(&block)
124-
end
125-
126-
def to_s
127-
to_html
123+
[to_s].each(&block)
128124
end
129125

130126
def to_str
131127
to_s
132128
end
133129

134-
def to_html
130+
def to_s
135131
content
136132
end
137133

lib/active_admin/arbre/html/tag.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def remove_class(class_names)
6565

6666
# Returns a string of classes
6767
def class_names
68-
class_list.to_html
68+
class_list.to_s
6969
end
7070

7171
def class_list
7272
get_attribute(:class) || set_attribute(:class, ClassList.new)
7373
end
7474

75-
def to_html
75+
def to_s
7676
indent("<#{tag_name}#{attributes_html}>", content, "</#{tag_name}>").html_safe
7777
end
7878

@@ -118,7 +118,7 @@ def child_is_text?
118118

119119

120120
def attributes_html
121-
attributes.any? ? " " + attributes.to_html : nil
121+
attributes.any? ? " " + attributes.to_s : nil
122122
end
123123

124124
def set_for_attribute(record)

lib/active_admin/arbre/html/text_node.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def tag_name
2626
nil
2727
end
2828

29-
def to_html
29+
def to_s
3030
ERB::Util.html_escape(@content.to_s)
3131
end
3232
end

lib/active_admin/views/components/columns.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def add_child(*)
1414
calculate_columns!
1515
end
1616

17+
def to_s
18+
super.to_s + "<div style=\"clear:both;\"></div>".html_safe
19+
end
20+
1721
protected
1822

1923
def margin_size
@@ -35,10 +39,6 @@ def calculate_columns!
3539
end
3640
end
3741

38-
def to_html
39-
super.to_s + "<div style=\"clear:both;\"></div>".html_safe
40-
end
41-
4242
end
4343

4444
class Column < ActiveAdmin::Component

spec/unit/arbre/context_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
end
2828

2929
it "should use a cached version of the HTML for method delegation" do
30-
current_dom_context.should_receive(:to_html).once.and_return("<h1>札幌市北区</h1>")
30+
current_dom_context.should_receive(:to_s).once.and_return("<h1>札幌市北区</h1>")
3131
current_dom_context.index('<').should == 0
3232
current_dom_context.index('<').should == 0
3333
end

0 commit comments

Comments
 (0)