Skip to content

Commit

Permalink
Merge remote branch 'haml/stable' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Oct 26, 2010
2 parents 2a787e9 + 43b4e23 commit 95e6cb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/haml/precompiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def locals_code(names)

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
Expand Down Expand Up @@ -320,7 +320,7 @@ def flush_merged_text
@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]
Expand Down Expand Up @@ -662,7 +662,7 @@ def parse_new_attributes(line)
if type == :static
static_attributes[name] = val
else
dynamic_attributes << inspect(name) << " => " << val << ","
dynamic_attributes << inspect_obj(name) << " => " << val << ","
end
end
dynamic_attributes << "}"
Expand Down Expand Up @@ -697,7 +697,7 @@ def parse_new_attribute(scanner)

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
Expand Down Expand Up @@ -802,7 +802,7 @@ def render_tag(line)
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
Expand All @@ -813,7 +813,7 @@ def render_tag(line)

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
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def contains_interpolation?(str)

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
Expand Down
4 changes: 2 additions & 2 deletions lib/haml/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ def set_eql?(set1, set2)
#
# @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
Expand Down

0 comments on commit 95e6cb7

Please sign in to comment.