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

Follow haml's weird behavior

This commit is contained in:
Takashi Kokubun 2015-03-29 02:10:28 +09:00
parent cfd98d33e1
commit 412063ba70

View file

@ -3,12 +3,17 @@ module Hamlit
class Plain
def compile(lines)
ast = [:multi]
lines.each_with_index do |line, index|
ast << [:static, "\n"] if index > 0
ast << [:haml, :text, line]
end
text = lines.join("\n")
ast << [:haml, :text, text]
ast << [:static, "\n"] if string_interpolated?(text)
ast
end
private
def string_interpolated?(text)
text =~ /\#{[^\#{}]*}/
end
end
end
end