1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Rename Util#inspect -> #inspect_obj.

Overriding #inspect made debugging hard.
This commit is contained in:
Nathan Weizenbaum 2010-10-25 23:30:46 -07:00
parent 8e9a8301ca
commit 43b4e23c03
2 changed files with 10 additions and 10 deletions

View file

@ -118,8 +118,8 @@ END
names.map do |name|
# Can't use || because someone might explicitly pass in false with a symbol
sym_local = "_haml_locals[#{inspect(name.to_sym)}]"
str_local = "_haml_locals[#{inspect(name.to_s)}]"
sym_local = "_haml_locals[#{inspect_obj(name.to_sym)}]"
str_local = "_haml_locals[#{inspect_obj(name.to_s)}]"
"#{name} = #{sym_local}.nil? ? #{str_local} : #{sym_local}"
end.join(';') + ';'
end
@ -320,7 +320,7 @@ END
@to_merge.each do |type, val, tabs|
case type
when :text
str << inspect(val)[1...-1]
str << inspect_obj(val)[1...-1]
mtabs += tabs
when :script
if mtabs != 0 && !@options[:ugly]
@ -662,7 +662,7 @@ END
if type == :static
static_attributes[name] = val
else
dynamic_attributes << inspect(name) << " => " << val << ","
dynamic_attributes << inspect_obj(name) << " => " << val << ","
end
end
dynamic_attributes << "}"
@ -697,7 +697,7 @@ END
return name, [:static, content.first[1]] if content.size == 1
return name, [:dynamic,
'"' + content.map {|(t, v)| t == :str ? inspect(v)[1...-1] : "\#{#{v}}"}.join + '"']
'"' + content.map {|(t, v)| t == :str ? inspect_obj(v)[1...-1] : "\#{#{v}}"}.join + '"']
end
# Parses a line that will render as an XHTML tag, and adds the code that will
@ -802,7 +802,7 @@ END
return if tag_closed
else
flush_merged_text
content = parse ? 'nil' : inspect(value)
content = parse ? 'nil' : inspect_obj(value)
if attributes_hashes.empty?
attributes_hashes = ''
elsif attributes_hashes.size == 1
@ -813,7 +813,7 @@ END
args = [tag_name, self_closing, !block_opened?, preserve_tag, escape_html,
attributes, nuke_outer_whitespace, nuke_inner_whitespace
].map {|v| inspect(v)}.join(', ')
].map {|v| inspect_obj(v)}.join(', ')
push_silent "_hamlout.open_tag(#{args}, #{object_ref}, #{content}#{attributes_hashes})"
@dont_tab_up_next_text = @dont_indent_next_line = dont_indent_next_line
end
@ -1019,7 +1019,7 @@ END
def unescape_interpolation(str, opts = {})
res = ''
rest = Haml::Shared.handle_interpolation inspect(str) do |scan|
rest = Haml::Shared.handle_interpolation inspect_obj(str) do |scan|
escapes = (scan[2].size - 1) / 2
res << scan.matched[0...-3 - escapes]
if escapes % 2 == 1

View file

@ -662,9 +662,9 @@ MSG
#
# @param obj {Object}
# @return {String}
def inspect(obj)
def inspect_obj(obj)
return obj.inspect unless version_geq(::RUBY_VERSION, "1.9.2")
return ':' + inspect(obj.to_s) if obj.is_a?(Symbol)
return ':' + inspect_obj(obj.to_s) if obj.is_a?(Symbol)
return obj.inspect unless obj.is_a?(String)
'"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"'
end