lib/faml/compiler.rb in faml-0.2.8 vs lib/faml/compiler.rb in faml-0.2.9

- old
+ new

@@ -226,11 +226,12 @@ if text.empty? return compile_static_id_and_class(static_id, static_class) end if attrs = try_optimize_attributes(text, static_id, static_class) - return [:html, :attrs, *attrs] + line_count = text.count("\n") + return [:multi, [:html, :attrs, *attrs]].concat([[:newline]] * line_count) end # Slow version h = {} @@ -273,9 +274,15 @@ return nil end if dynamic_attributes.has_key?('data') # XXX: Quit optimization... + return nil + end + + if text.include?("\n") && !dynamic_attributes.empty? + # XXX: Quit optimization to keep newlines + # https://github.com/eagletmt/faml/issues/18 return nil end (static_attributes.keys + dynamic_attributes.keys).sort.flat_map do |k| if static_attributes.has_key?(k)