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

Merge pull request #933 from zetaben/listof-strip

Fix list_of helper with multi-line content
This commit is contained in:
Takashi Kokubun 2017-05-25 21:00:29 +09:00 committed by GitHub
commit b61c6bc2c5
2 changed files with 3 additions and 1 deletions

View file

@ -206,7 +206,7 @@ MESSAGE
if result.count("\n") > 1
result.gsub!("\n", "\n ")
result = "\n #{result.strip!}\n"
result = "\n #{result.strip}\n"
else
result.strip!
end

View file

@ -83,6 +83,8 @@ HAML
assert_equal("<li>[1]</li>", render("= list_of([[1]]) do |i|\n = i.inspect"))
assert_equal("<li>\n <h1>Fee</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fi</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fo</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fum</h1>\n <p>A word!</p>\n</li>",
render("= list_of(['Fee', 'Fi', 'Fo', 'Fum']) do |title|\n %h1= title\n %p A word!"))
assert_equal("<li>\n <f>a\n \n a</f>\n</li>\n<li>\n <f>a\n \n a</f>\n</li>",
render("= list_of(['Fee', 'Fi']) do |title|\n %f>= \"a\\n\\na\""))
assert_equal("<li c='3'>1</li>\n<li c='3'>2</li>", render("= list_of([1, 2], {:c => 3}) do |i|\n = i"))
assert_equal("<li c='3'>[1]</li>", render("= list_of([[1]], {:c => 3}) do |i|\n = i.inspect"))
assert_equal("<li c='3'>\n <h1>Fee</h1>\n <p>A word!</p>\n</li>\n<li c='3'>\n <h1>Fi</h1>\n <p>A word!</p>\n</li>\n<li c='3'>\n <h1>Fo</h1>\n <p>A word!</p>\n</li>\n<li c='3'>\n <h1>Fum</h1>\n <p>A word!</p>\n</li>",