class Haml::DynamicMerger

def merge_dynamic(exps)

def merge_dynamic(exps)
  # Merge exps only when they have both :static and :dynamic
  unless exps.any? { |type,| type == :static } && exps.any? { |type,| type == :dynamic }
    return exps
  end
  strlit_body = String.new
  exps.each do |type, arg|
    case type
    when :static
      strlit_body << arg.dump.sub!(/\A"/, '').sub!(/"\z/, '').gsub('\n', "\n")
    when :dynamic
      strlit_body << "\#{#{arg}}"
    when :newline
      # newline is added by `gsub('\n', "\n")`
    else
      raise "unexpected type #{type.inspect} is given to #merge_dynamic"
    end
  end
  [[:dynamic, "%Q\0#{strlit_body}\0"]]
end