mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Escape interpolation
This commit is contained in:
parent
c97f17d7ed
commit
e2da721bc5
2 changed files with 6 additions and 8 deletions
|
@ -12,11 +12,9 @@ module Hamlit
|
||||||
text = node.value[:text].rstrip
|
text = node.value[:text].rstrip
|
||||||
if Haml::Util.contains_interpolation?(text)
|
if Haml::Util.contains_interpolation?(text)
|
||||||
# FIXME: Confirm whether this is correct or not
|
# FIXME: Confirm whether this is correct or not
|
||||||
if @pretty
|
text << "\n".freeze unless @pretty
|
||||||
[:dynamic, Haml::Util.unescape_interpolation(text)]
|
text = Haml::Util.unescape_interpolation(text)
|
||||||
else
|
[:escape, true, [:dynamic, text]]
|
||||||
[:dynamic, Haml::Util.unescape_interpolation(text + "\n")]
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
[:static, text]
|
[:static, text]
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,7 +66,7 @@ class FiltersTest < Haml::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should respect escaped newlines and interpolation" do; skip
|
test "should respect escaped newlines and interpolation" do
|
||||||
html = "\\n\n"
|
html = "\\n\n"
|
||||||
haml = ":plain\n \\n\#{""}"
|
haml = ":plain\n \\n\#{""}"
|
||||||
assert_equal(html, render(haml))
|
assert_equal(html, render(haml))
|
||||||
|
@ -117,7 +117,7 @@ class FiltersTest < Haml::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "interpolated code should be escaped if escape_html is set" do; skip
|
test "interpolated code should be escaped if escape_html is set" do
|
||||||
assert_equal "<script>evil</script>\n",
|
assert_equal "<script>evil</script>\n",
|
||||||
render(":plain\n \#{'<script>evil</script>'}", :escape_html => true)
|
render(":plain\n \#{'<script>evil</script>'}", :escape_html => true)
|
||||||
end
|
end
|
||||||
|
@ -264,4 +264,4 @@ class RubyFilterTest < Haml::TestCase
|
||||||
html = "7\n"
|
html = "7\n"
|
||||||
assert_equal(html, render(haml))
|
assert_equal(html, render(haml))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue