Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed any references to to_html within our Arbre components (use to_s)

  • Loading branch information...
commit 43bc2a874f7d3e42b05fb5e3102a5bc2868bb24c 1 parent 67e27b9
@gregbell gregbell authored
View
2  lib/active_admin/arbre/context.rb
@@ -35,7 +35,7 @@ def cached_html
if defined?(@cached_html)
@cached_html
else
- html = to_html
+ html = to_s
@cached_html = html if html.length > 0
html
end
View
2  lib/active_admin/arbre/html/attributes.rb
@@ -3,7 +3,7 @@ module HTML
class Attributes < Hash
- def to_html
+ def to_s
self.collect do |name, value|
"#{html_escape(name)}=\"#{html_escape(value)}\""
end.join(" ")
View
4 lib/active_admin/arbre/html/class_list.rb
@@ -15,10 +15,6 @@ def add(class_names)
alias :<< :add
def to_s
- to_html
- end
-
- def to_html
to_a.join(" ")
end
View
4 lib/active_admin/arbre/html/collection.rb
@@ -16,9 +16,9 @@ def &(other)
self.class.new(super)
end
- def to_html
+ def to_s
self.collect do |element|
- element.to_html
+ element.to_s
end.join.html_safe
end
end
View
2  lib/active_admin/arbre/html/document.rb
@@ -21,7 +21,7 @@ def doctype
'<!DOCTYPE html>'.html_safe
end
- def to_html
+ def to_s
doctype + super
end
View
12 lib/active_admin/arbre/html/element.rb
@@ -108,11 +108,11 @@ def get_elements_by_class_name(class_name)
alias_method :find_by_class, :get_elements_by_class_name
def content
- children.to_html
+ children.to_s
end
def html_safe
- to_html
+ to_s
end
def indent_level
@@ -120,18 +120,14 @@ def indent_level
end
def each(&block)
- [to_html].each(&block)
- end
-
- def to_s
- to_html
+ [to_s].each(&block)
end
def to_str
to_s
end
- def to_html
+ def to_s
content
end
View
6 lib/active_admin/arbre/html/tag.rb
@@ -65,14 +65,14 @@ def remove_class(class_names)
# Returns a string of classes
def class_names
- class_list.to_html
+ class_list.to_s
end
def class_list
get_attribute(:class) || set_attribute(:class, ClassList.new)
end
- def to_html
+ def to_s
indent("<#{tag_name}#{attributes_html}>", content, "</#{tag_name}>").html_safe
end
@@ -118,7 +118,7 @@ def child_is_text?
def attributes_html
- attributes.any? ? " " + attributes.to_html : nil
+ attributes.any? ? " " + attributes.to_s : nil
end
def set_for_attribute(record)
View
2  lib/active_admin/arbre/html/text_node.rb
@@ -26,7 +26,7 @@ def tag_name
nil
end
- def to_html
+ def to_s
ERB::Util.html_escape(@content.to_s)
end
end
View
8 lib/active_admin/views/components/columns.rb
@@ -14,6 +14,10 @@ def add_child(*)
calculate_columns!
end
+ def to_s
+ super.to_s + "<div style=\"clear:both;\"></div>".html_safe
+ end
+
protected
def margin_size
@@ -35,10 +39,6 @@ def calculate_columns!
end
end
- def to_html
- super.to_s + "<div style=\"clear:both;\"></div>".html_safe
- end
-
end
class Column < ActiveAdmin::Component
View
2  spec/unit/arbre/context_spec.rb
@@ -27,7 +27,7 @@
end
it "should use a cached version of the HTML for method delegation" do
- current_dom_context.should_receive(:to_html).once.and_return("<h1>札幌市北区</h1>")
+ current_dom_context.should_receive(:to_s).once.and_return("<h1>札幌市北区</h1>")
current_dom_context.index('<').should == 0
current_dom_context.index('<').should == 0
end
View
10 spec/unit/arbre/html/element_spec.rb
@@ -73,7 +73,7 @@
let(:child){ "Hello World" }
it "should add as a TextNode" do
element.children.first.should be_instance_of(Arbre::HTML::TextNode)
- element.children.first.to_html.should == "Hello World"
+ element.children.first.to_s.should == "Hello World"
end
end
end
@@ -90,13 +90,13 @@
end
it "should add the string as a child" do
- element.children.first.to_html.should == "Goodbye"
+ element.children.first.to_s.should == "Goodbye"
end
it "should html escape the string" do
string = "Goodbye <br />"
element.content = string
- element.to_html.should == "Goodbye &lt;br /&gt;"
+ element.to_s.should == "Goodbye &lt;br /&gt;"
end
end
@@ -146,8 +146,8 @@
describe "rendering to html" do
it "should render the children collection" do
- element.children.should_receive(:to_html).and_return("content")
- element.to_html.should == "content"
+ element.children.should_receive(:to_s).and_return("content")
+ element.to_s.should == "content"
end
end
View
6 spec/unit/arbre/html/tag_attributes_spec.rb
@@ -14,7 +14,7 @@
end
it "should render the attributes to html" do
- tag.to_html.should == <<-HTML
+ tag.to_s.should == <<-HTML
<tag id="my_id"></tag>
HTML
end
@@ -47,13 +47,13 @@
describe "rendering attributes" do
it "should html safe the attribute values" do
tag.set_attribute(:class, "\">bad things!")
- tag.to_html.should == <<-HTML
+ tag.to_s.should == <<-HTML
<tag class="&quot;&gt;bad things!"></tag>
HTML
end
it "should should escape the attribute names" do
tag.set_attribute(">bad", "things")
- tag.to_html.should == <<-HTML
+ tag.to_s.should == <<-HTML
<tag &gt;bad="things"></tag>
HTML
end
View
34 spec/unit/arbre/html_spec.rb
@@ -6,7 +6,7 @@
it "should render a single element" do
content = span("Hello World")
- content.to_html.should == <<-HTML
+ content.to_s.should == <<-HTML
<span>Hello World</span>
HTML
end
@@ -15,7 +15,7 @@
content = span do
span "Hello World"
end
- content.to_html.should == <<-HTML
+ content.to_s.should == <<-HTML
<span>
<span>Hello World</span>
</span>
@@ -28,7 +28,7 @@
li "Second"
li "Third"
end
- content.to_html.should == <<-HTML
+ content.to_s.should == <<-HTML
<ul>
<li>First</li>
<li>Second</li>
@@ -51,7 +51,7 @@
li first
li second
end
- content.to_html.should == <<-EOS
+ content.to_s.should == <<-EOS
<ul>
<li>First</li>
<li>Second</li>
@@ -66,7 +66,7 @@
li
end
end
- content.to_html.should == <<-HTML
+ content.to_s.should == <<-HTML
<div>
<ul></ul>
<li>
@@ -82,7 +82,7 @@
li
end
end
- content.to_html.should == <<-HTML
+ content.to_s.should == <<-HTML
<div>
<ul>
<li></li>
@@ -95,7 +95,7 @@
content = div do
span(ul(li))
end
- content.to_html.should == <<-HTML
+ content.to_s.should == <<-HTML
<div>
<span>
<ul>
@@ -113,7 +113,7 @@
li
end
end
- content.to_html.should == <<-HTML
+ content.to_s.should == <<-HTML
<div id="my-tag">
<ul>
<li></li>
@@ -134,7 +134,7 @@
it "should set a string content return value with no children" do
li do
"Hello World"
- end.to_html.should == <<-HTML
+ end.to_s.should == <<-HTML
<li>Hello World</li>
HTML
end
@@ -150,19 +150,19 @@
describe "self-closing nodes" do
it "should not self-close script tags" do
tag = script :type => 'text/javascript'
- tag.to_html.should == <<-HTML
+ tag.to_s.should == <<-HTML
<script type="text/javascript"></script>
HTML
end
it "should self-close meta tags" do
tag = meta :content => "text/html; charset=utf-8"
- tag.to_html.should == <<-HTML
+ tag.to_s.should == <<-HTML
<meta content="text/html; charset=utf-8\"/>
HTML
end
it "should self-close link tags" do
tag = link :rel => "stylesheet"
- tag.to_html.should == <<-HTML
+ tag.to_s.should == <<-HTML
<link rel="stylesheet"/>
HTML
end
@@ -170,17 +170,17 @@
describe "html safe" do
it "should escape the contents" do
- span("<br />").to_html.should == <<-HTML
+ span("<br />").to_s.should == <<-HTML
<span>&lt;br /&gt;</span>
HTML
end
it "should return html safe strings" do
- span("<br />").to_html.should be_html_safe
+ span("<br />").to_s.should be_html_safe
end
it "should not escape html passed in" do
- span(span("<br />")).to_html.should == <<-HTML
+ span(span("<br />")).to_s.should == <<-HTML
<span>
<span>&lt;br /&gt;</span>
</span>
@@ -192,7 +192,7 @@
span {
"<br />"
}
- }.to_html.should == <<-HTML
+ }.to_s.should == <<-HTML
<span>
<span>&lt;br /&gt;</span>
</span>
@@ -200,7 +200,7 @@
end
it "should escape the contents of attributes" do
- span(:class => "<br />").to_html.should == <<-HTML
+ span(:class => "<br />").to_s.should == <<-HTML
<span class="&lt;br /&gt;"></span>
HTML
end
Please sign in to comment.
Something went wrong with that request. Please try again.