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

Deprecate unescape_interpolation

This commit is contained in:
Takashi Kokubun 2015-11-23 00:27:18 +09:00
parent 6a69515606
commit b37434cfec
7 changed files with 12 additions and 12 deletions

View file

@ -11,7 +11,7 @@ module Hamlit
def compile_text(text)
if ::Hamlit::HamlUtil.contains_interpolation?(text)
[:dynamic, ::Hamlit::HamlUtil.unescape_interpolation(text)]
[:dynamic, ::Hamlit::HamlUtil.slow_unescape_interpolation(text)]
else
[:static, text]
end

View file

@ -6,7 +6,7 @@ module Hamlit
if ::Hamlit::HamlUtil.contains_interpolation?(text)
# FIXME: Confirm whether this is correct or not
text << "\n".freeze
text = ::Hamlit::HamlUtil.unescape_interpolation(text)
text = ::Hamlit::HamlUtil.slow_unescape_interpolation(text)
[:escape, true, [:dynamic, text]]
else
[:static, text]

View file

@ -11,7 +11,7 @@ module Hamlit
def compile_text(text)
if ::Hamlit::HamlUtil.contains_interpolation?(text)
[:dynamic, ::Hamlit::HamlUtil.unescape_interpolation(text)]
[:dynamic, ::Hamlit::HamlUtil.slow_unescape_interpolation(text)]
else
[:static, text]
end

View file

@ -5,7 +5,7 @@ module Hamlit
text = node.value[:text].rstrip.gsub(/^/, prefix)
if ::Hamlit::HamlUtil.contains_interpolation?(node.value[:text])
# original: Haml::Filters#compile
text = ::Hamlit::HamlUtil.unescape_interpolation(text).gsub(/(\\+)n/) do |s|
text = ::Hamlit::HamlUtil.slow_unescape_interpolation(text).gsub(/(\\+)n/) do |s|
escapes = $1.size
next s if escapes % 2 == 0
"#{'\\' * (escapes - 1)}\n"

View file

@ -33,7 +33,7 @@ module Hamlit
def dynamic_compile(node, name, indent_width: 0)
# original: Haml::Filters#compile
text = ::Hamlit::HamlUtil.unescape_interpolation(node.value[:text]).gsub(/(\\+)n/) do |s|
text = ::Hamlit::HamlUtil.slow_unescape_interpolation(node.value[:text]).gsub(/(\\+)n/) do |s|
escapes = $1.size
next s if escapes % 2 == 0
"#{'\\' * (escapes - 1)}\n"

View file

@ -284,7 +284,7 @@ module Hamlit
end
escape_html = @options.escape_html if escape_html.nil?
line.text = unescape_interpolation(line.text, escape_html)
line.text = slow_unescape_interpolation(line.text, escape_html)
script(line, false)
end
@ -373,7 +373,7 @@ module Hamlit
when '='
parse = true
if value[0] == ?=
value = unescape_interpolation(value[1..-1].strip, escape_html)
value = slow_unescape_interpolation(value[1..-1].strip, escape_html)
escape_html = false
end
when '&', '!'
@ -381,19 +381,19 @@ module Hamlit
parse = true
preserve_script = (value[0] == ?~)
if value[1] == ?=
value = unescape_interpolation(value[2..-1].strip, escape_html)
value = slow_unescape_interpolation(value[2..-1].strip, escape_html)
escape_html = false
else
value = value[1..-1].strip
end
elsif contains_interpolation?(value)
value = unescape_interpolation(value, escape_html)
value = slow_unescape_interpolation(value, escape_html)
parse = true
escape_html = false
end
else
if contains_interpolation?(value)
value = unescape_interpolation(value, escape_html)
value = slow_unescape_interpolation(value, escape_html)
parse = true
escape_html = false
end
@ -458,7 +458,7 @@ module Hamlit
if contains_interpolation?(text)
parse = true
text = unescape_interpolation(text)
text = slow_unescape_interpolation(text)
else
parse = false
end

View file

@ -198,7 +198,7 @@ MSG
/#[\{$@]/ === str
end
def unescape_interpolation(str, escape_html = nil)
def slow_unescape_interpolation(str, escape_html = nil)
res = ''
rest = ::Hamlit::HamlUtil.handle_interpolation str.dump do |scan|
escapes = (scan[2].size - 1) / 2